Hi
Could anyone help me with this problem, I am trying to use php to insert user record into table (tblusers) using mysql command but I do get this error (Parse error: parse error, unexpected ';' in register.php on line 30 ) I don’t know what is wrong with it any help will be highly appreciated.
Kind Regards
HB25
The could I am using on line 30 is :

$query = "INSERT INTO `".$conf['sql_tbprefix']."tblusers` (`Username`,`Password`,`firstname`,`surname`,`address1`,`address2`,`town`,`postcode`,`telephone`,`email`) VALUES('".mysql_real_escape_string($username)."','".md5(mysql_real_escape_string($password))."', '".mysql_real_escape_string($address1)."', '".mysql_real_escape_string($address2)."', '".mysql_real_escape_string($town)."', '".mysql_real_escape_string($postcode)."', '".mysql_real_escape_string($telephone)."', '".mysql_real_escape_string($email)."')";

Dani AI

Generated

For — the PHP error shown is a parser problem, not an SQL runtime error. As suggested, a missing semicolon on the line above or an unclosed quote/parenthesis will cause "unexpected ';'". As noted, breaking the long expression into smaller parts makes these mistakes obvious. Quick diagnostics: run php -l register.php to check syntax, and temporarily enable ini_set('display_errors',1); error_reporting(E_ALL); so PHP points to the exact line.

Also check the INSERT itself: the column list and the VALUES list must have the same number of items. In the original statement two columns are listed but not provided in VALUES, which will cause a SQL error once the PHP parse problem is fixed. Fix either by adding the missing values or removing the extra column names.

Modern, safer approach: use prepared statements and a strong password hash to avoid manual escaping and reduce syntax complexity. Example (mysqli style):

$mysqli = new mysqli($host,$user,$pass,$db);
$stmt = $mysqli->prepare(
  "INSERT INTO {$conf['sql_tbprefix']}tblusers
   (Username,Password,firstname,surname,address1,address2,town,postcode,telephone,email)
   VALUES (?,?,?,?,?,?,?,?,?,?)"
);
$hashed = password_hash($password, PASSWORD_DEFAULT);
$stmt->bind_param("ssssssssss",$username,$hashed,$firstname,$surname,$address1,$address2,$town,$postcode,$telephone,$email);
$stmt->execute();

Checklist: run php -l, enable error reporting, confirm balanced quotes/parentheses, ensure columns match values, and prefer prepared statements plus password_hash over manual md5 or concatenated queries.

Recommended Answers

All 2 Replies

i am guessing you forgot a semicolon on the line above this one, but I am not sure.

This error comes due to some problem in the syntax of query, divide your query into small pieces means just try to enter data first for one field only and also check the comma and inverted commas you are using are correct

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.