this code worked for 4 years until host stopped supporting php4......
This script follows a login script which sets session and checks to see if the user is valid.
If valid the following script is run and now shows the error....
Couldn't execute query because: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2
I'm afraid it has me beat! not that I am an experienced programmer, but I would appreciate anyone being able to point out why the query fails to execute.
Thanks in anticipation.
- Code: Select all
<?php
/* Program name: upd_user_details.php
* Description: Script displays a form with address
* information obtained from the database.
*/
session_start();
//set session variables for students id number
$_SESSION['studentid'] = "$studentid";
$studentid = $_SESSION['studentid'];
$_SESSION['f_name'] = "$f_name";
$f_name = $_SESSION['f_name'];
$_SESSION['l_name'] = "$l_name";
$l_name = $_SESSION['l_name'];
$_SESSION['email'] = "$email";
$email = $_SESSION['email'];
echo "<html>
<head><title>Student Details</title></head>
<body>";
// create an array that contains the labels used in the form
// the keys are the field names.
$labels = array( "f_name"=>"First Name:",
"l_name"=>"Last Name (Surname/Family):",
"salutation"=>"Dr/Mr/Mrs/Ms:",
"gender"=>"Gender (m or f) :",
"birthdate"=>"Date of Birth (yyyy-mm-dd):",
"email"=>"Email Address:",
"address1"=>"Street Address 1:",
"address2"=>"Street Address 2:",
"address3"=>"City or Town:",
"state"=>"State:",
"zip"=>"Zipcode or Postcode:",
"country"=>"Country:",
"occupation"=>"Occupation: ");
$user="distanceed";
$host="mysql39.secureserver.net";
$password="not shown";
$database = "distanceed";
$conn = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$conn)
or die ("Couldn't select database");
$query = "SELECT * FROM auth_users
WHERE id = $studentid ";
$result = mysql_query($query) or die("Couldn't execute query because: ".mysql_error());
$row = mysql_fetch_array($result);
echo "<p align='center'>
<h1 align='center'>Details for $f_name $l_name </h1>\n";
echo "<br><p align='center'>
<font size='+1'><b>Please check the information below
and change any information that is incorrect.
</b></font>";
echo "<br><p align='center'>
<font size='+1'><b>DO NOT LEAVE ANY FIELDS BLANK
</b></font>
<hr>";
echo "<form action=process_changes.php method='POST'>
<table width='95%' border='0' cellspacing='0'
cellpadding='2'>\n";
foreach($labels as $field=>$label)
{
echo "<tr>
<td align='right'> <B>{$labels[$field]} </br></td>
<td><input type='text' name='$field'
value='$row[$field]' size='65' maxlength='65'>
</td>
</tr>";
}
echo "</table>
<div align='center'><p><input type='submit' value='Update Correct Details'> </p></div>
</form>";
?>
</body></html>


