Page 1 of 1

Code Check

Posted: Fri Apr 02, 2004 8:26 pm
by AliasBDI
Using PHP and MySQL:

Here is the error:
Parse error: parse error, expecting `','' or `';'' in /home/httpd/vhosts/ticketblasters.com/httpdocs/econtrol/register/updateRegistration/_register.php on line 24
My code reads this on line 24:

Code: Select all

$query = "UPDATE registration SET student_id = '$student_id', schedule_id = '$schedule_id', reason = '$reason' WHERE id = '$regID'"; $sql = mysql_query($query) or die("ERROR");
Any ideas? Here is the page code just in case:

Code: Select all

<?php
session_register();
include 'connect.php';

// Convert to simple variables
$student_id = $_POST&#1111;'student_id'];
$schedule_id = $_POST&#1111;'schedule_id'];
$first_name = $_POST&#1111;'first_name'];
$last_name = $_POST&#1111;'last_name'];
$location = $_POST&#1111;'location'];
$month = $_POST&#1111;'month'];
$day = $_POST&#1111;'day'];
$year = $_POST&#1111;'year'];
$time_in = $_POST&#1111;'time_in'];
$fee = $_POST&#1111;'fee'];
$email_address = $_POST&#1111;'email_address'];
$locationNO = str_replace(" ","%20",$location);
$reason = $_POST&#1111;'reason'];
$regID = $_POST&#1111;'regID'];

echo $student_id; echo " "; echo $schedule_id; echo " "; echo $reason' echo " "; echo $regID; exit

// Enter info into the Database.
$query = "UPDATE registration SET student_id = '$student_id', schedule_id = '$schedule_id', reason = '$reason' WHERE id = '$regID'"; $sql = mysql_query($query) or die("ERROR"); 


if(!$query)&#123;
	echo 'There has been an error registering your class. Please contact the webmaster.';
&#125; else &#123;
	$id = mysql_insert_id();
	$activatepath = "/schedule/_success.php?scheduleID=$schedule_id&studentID=$student_id";


// Let's mail the user!
$subject = "Class Registration at $sitename";
$message = "Dear $first_name $last_name,


You are now registered for a Ticket Blaster Defense Driving class on $month $day, $year at $location!  Class begins promptly at $time_in.  To save time and secure your registration, it is recommended that you prepay for the class online using most credit cards at PayPal.com.  Click on the following link for payment details:
https://www.paypal.com/xclick/business=tilmon@ev1.net&item_name=TB%20REGISTRATION%20for%20$locationNO%20on%20$month,%20$day%20$year&item_number=$id&amount=$fee&no_note=1&currency_code=USD
(OR copy/paste the address into your address bar).  You can also call us and pay over the phone using a major credit card, 281-457-6700.

Thanks!
$sitename
http://www.ticketblasters.com
bs:281.457.6700


This is an automated response, please do not reply!";

mail($email_address, $subject, $message, "From: $sitename <$adminemail>\nX-Mailer: PHP/" . phpversion());
header('Location: _success_register.php'); ;
&#125;


?>

Posted: Fri Apr 02, 2004 8:37 pm
by markl999

Code: Select all

echo $student_id; echo " "; echo $schedule_id; echo " "; echo $reason' echo " "; echo $regID; exit
Missing the final ;

exit;

hmm.

Posted: Fri Apr 02, 2004 9:00 pm
by AliasBDI
Actually that was just for testing purposes. I need the UPDATE query to work. Here is my actual code:

Code: Select all

<?php
session_register();
include '../../../includes/db.php';

// Convert to simple variables
$student_id = $_POST&#1111;'student_id'];
$schedule_id = $_POST&#1111;'schedule_id'];
$first_name = $_POST&#1111;'first_name'];
$last_name = $_POST&#1111;'last_name'];
$location = $_POST&#1111;'location'];
$month = $_POST&#1111;'month'];
$day = $_POST&#1111;'day'];
$year = $_POST&#1111;'year'];
$time_in = $_POST&#1111;'time_in'];
$fee = $_POST&#1111;'fee'];
$email_address = $_POST&#1111;'email_address'];
$locationNO = str_replace(" ","%20",$location);
$reason = $_POST&#1111;'reason'];
$regID = $_POST&#1111;'regID'];


// Enter info into the Database.
$query = "UPDATE registration SET student_id = '$student_id', schedule_id = '$schedule_id', reason = '$reason' WHERE id = '$regID'"; $sql = mysql_query($query) or die("ERROR"); 


if(!$query)&#123;
	echo 'There has been an error registering your class. Please contact the webmaster.';
&#125; else &#123;
	$id = mysql_insert_id();
	$activatepath = "/schedule/_success.php?scheduleID=$schedule_id&studentID=$student_id";


// Let's mail the user!
$subject = "Class Registration at $sitename";
$message = "Dear $first_name $last_name,


You are now registered for a Ticket Blaster Defense Driving class on $month $day, $year at $location!  Class begins promptly at $time_in.  To save time and secure your registration, it is recommended that you prepay for the class online using most credit cards at PayPal.com.  Click on the following link for payment details:
https://www.paypal.com/xclick/business=tilmon@ev1.net&item_name=TB%20REGISTRATION%20for%20$locationNO%20on%20$month,%20$day%20$year&item_number=$id&amount=$fee&no_note=1&currency_code=USD
(OR copy/paste the address into your address bar).  You can also call us and pay over the phone using a major credit card, 281-457-6700.

Thanks!
$sitename
http://www.ticketblasters.com
bs:281.457.6700


This is an automated response, please do not reply!";

mail($email_address, $subject, $message, "From: $sitename <$adminemail>\nX-Mailer: PHP/" . phpversion());
header('Location: _success_register.php'); ;
&#125;

?>
Now, I'm not getting an error but the UPDATE query is not working. It is doing nothing. The test worked fine so the variables in POST are passing perfectly. Any ideas?

Posted: Fri Apr 02, 2004 9:10 pm
by markl999
If you echo $query; just before the mysql_query bit does it look ok?

Posted: Fri Apr 02, 2004 9:11 pm
by kettle_drum
Try to update only one field at a time.

hey

Posted: Fri Apr 02, 2004 9:31 pm
by AliasBDI
I tried that. All of the fields are REAL in the database and since there are no errors, I cannot tell what is really going on. Is there another way to test it?

Here is my code does it check out?

Code: Select all

$query = "UPDATE registration SET student_id = '$student_id', schedule_id = '$schedule_id', reason = '$reason' WHERE id = '$regID'"; $sql = mysql_query($query) or die("ERROR");

Posted: Fri Apr 02, 2004 9:33 pm
by markl999
What does echo $query; show ?

ahhh.

Posted: Fri Apr 02, 2004 9:59 pm
by AliasBDI
It shows:

Code: Select all

UPDATE registration SET student_id = '1000033', schedule_id = '124', reason = '2' WHERE id = ''
Apparently my regID is not passing!!! But why isn't it? It works on the testing...!

ah ha.

Posted: Fri Apr 02, 2004 10:02 pm
by AliasBDI
I got it... my error was in the form page. It lacked the echo $regID.

THanks for you help guys.! :D