試圖允許php使用相同的變量查詢來拉'代碼'和'前綴'字段。爲什麼PHP會拋出這個錯誤?
錯誤:'code'
<script type="text/javascript">
$(document).ready(function() {
$("#ProfFields,#courseFields").hide();
$("input:radio[name='addType']").click(function(){
var profFields = ($(this).val()=="Professor");
$("#ProfFields").toggle(profFields);
$("#courseFields").toggle(!profFields);
});
});
</script>
<?php
require_once('inc/dbc1.php');
$pdo = new PDO('mysql:host=ureviewdu.db.6511651.hostedresource.com;dbname=ureviewdu', $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sth = $pdo->prepare('
SELECT name
FROM Department
;');
$sth->execute(array());
$pdo2 = new PDO('mysql:host=####;dbname=###', $username, $password);
$pdo2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sth2 = $pdo2->prepare('
SELECT prefix, code FROM Course
;');
$sth2->execute(array());
?>
<div id="popup_name" class="popup_block">
<h2 style="padding:0; margin:0;">Add a:</h2><br>
<form action="inc/add_p_c_validate.php" method="post" id="addition">
Professor<input type="radio" name="addType" value="Professor" />
Course<input type="radio" name="addType" value="Course" />
<div id="courseFields">
Course[Prefix]: <select name="cPrefix" id="cPrefix" style="width:150px;" />
<?php while($row2 = $sth2->fetch(PDO::FETCH_ASSOC)) {echo "<option>".$row2['prefix']." "."</option><br>";} ?> </select>
Course[Code]: <select name="cCode" id="cCode" style="width:150px;" />
<?php while($row2 = $sth2->fetch(PDO::FETCH_ASSOC)) {echo "<option>".$row2['code']." "."</option>";} ?></select>
Department: <select name="deptName" id="deptName" style="width:350px;">
<?php while($row = $sth->fetch(PDO::FETCH_ASSOC)) {echo "<option>".$row['name']." "."</option>";} ?></select>
Email: <input type="text" name="email" class="l" />
</div><!--/courseFields-->
<div id="ProfFields">
<br>First Name: <input type="text" name="name" style="width:385px;" /><br>
<br>Last Name: <input type="text" name="name" style="width:385px;" /><br>
Department: <select name="deptName" id="deptName" style="width:350px;">
</div><!--/ProfFields-->
<input type="submit" name="submit" />
</form>
</div><!--popup_name-->
'課程[代碼]:'這是無效的PHP代碼 – zerkms 2011-04-20 23:45:31
請參閱更新的代碼和錯誤。 – Jshee 2011-04-21 00:04:21
@ user700070:這是_actually_您收到的錯誤消息嗎? – 2011-04-21 00:09:41