1
我有一個問題我的腳本有三個mysql_query
應後相互使用,我想創建一個腳本,預訂門票通過改變他們的身份售出=「無」到「有」 ,該腳本計算用戶在html表單上輸入的票數,該表單向服務器端提供了一個變量,其中包含票數= $tickets
。PHP的MySQL fetch語句獲取問題
提示:這是這樣一個模型,以便無需MySQL的注射安全
這裏是我的代碼:
//get ticket status
$eventTicket = mysql_query("SELECT eventTickets FROM beventreservation WHERE eventId = '$eventId'") or die(mysql_error());
$ticketrow = mysql_fetch_array($eventTicket) or die(mysql_error());
//test... which is working !
echo $ticketrow['eventTickets'];
//get classId from classes
$selectClass = mysql_query("SELECT classId FROM quotaclasses WHERE className = '$classes' AND eventFK = '$eventId'") or die (mysql_error());
$classrow = mysql_fetch_array($selectClass) or die(mysql_error());
//this var is to define which class the user used
$choosedClass = $classrow['classId'];
//test ... which did not work !!!
echo $classrow['classId'];
if ($ticketrow['eventTickets'] == "Yes")
{
for($counter=1;$counter<$numberOfTickets;$counter++)
{
$bookTicket = mysql_query("UPDATE unites SET ticketSold = 'Yes' WHERE businessreservationIdFk = '$eventId' AND classIDfk ='$choosedClass'") or die(mysql_error());
echo "ticket ". $counter . " done !";
}
}
腳本不取此語法,並沒有錯誤顯示在我的頁面上!
$classrow = mysql_fetch_array($selectClass) or die(mysql_error());
還,我想這句法後呼應變量$tickets
,它沒有露面,有沒有要讀取的mysql_query多個相同的腳本頁面上的問題嗎?請告訴我,我在哪裏錯了。