abch624 Posted November 3, 2007 Share Posted November 3, 2007 I have an sql statement in a php file, when the code reaches this line then it give me an error "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\join.php on line 131".... $sql = "UPDATE venue SET name='$_POST['venu_name']', address1='$_POST['address']', city='$_POST['city'], postcode='$_POST['postcode']', telephone='$_POST['telephone']', fax='$_POST['fax']', email='$_POST['email']', contactname='$_POST['contactname']' WHERE venueid='$_POST['$result3']'"; Please any help... Quote Link to comment Share on other sites More sharing options...
ChrisMayhew Posted November 3, 2007 Share Posted November 3, 2007 I have just had a quick look through that and i can see that this part doesn't have a closing ' city='$_POST['city']', Quote Link to comment Share on other sites More sharing options...
abch624 Posted November 3, 2007 Author Share Posted November 3, 2007 I have just had a quick look through that and i can see that this part doesn't have a closing ' city='$_POST['city']', Pointed out well, but doesnt work still, same error Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 3, 2007 Share Posted November 3, 2007 Use concatenations the single quotes in the index's are messing it up <?php //example city='".$_POST['city']."' ?> Quote Link to comment Share on other sites More sharing options...
abch624 Posted November 3, 2007 Author Share Posted November 3, 2007 Use concatenations the single quotes in the index's are messing it up <?php //example city='".$_POST['city']."' ?> Tried doesnt work I thought of just putting all the code The code that generates the error: <?php include $_SERVER['DOCUMENT_ROOT'].'/mini.php'; include $_SERVER['DOCUMENT_ROOT'].'/layout.php'; switch($_REQUEST['req']){ case "process": // Validate all required fields were posted if(!$_POST['venu_name'] || !$_POST['address'] || !$_POST['city'] || !$_POST['postcode'] || !$_POST['telephone'] || !$_POST['fax'] || !$_POST['email'] || !$_POST['contactname']){ $error = true; $errors .= "<strong>Form Input Errors:". "</strong>\n\n"; if(!$_POST['venu_name']){ $errors .= "Missing Venu Name\n"; } if(!$_POST['address']){ $errors .= "Missing Address\n"; } if(!$_POST['city']){ $errors .= "Missing City Name\n"; $email_error = true; } if(!$_POST['postcode']){ $errors .= "Missing Post Code". "Verification\n"; $email_error = true; } if(!$_POST['telephone']){ $errors .= "Missing Telephone Number\n"; } if(!$_POST['fax']){ $errors .= "Missing Fax Number\n"; $password_error = true; } if(!$_POST['email']){ $errors .= "Missing Email\n"; $password_error = true; } if(!$_POST['contactname']){ $errors .= "Missing Contact Name\n"; } } // If both emails were posted, validate they match. if($email_error == false){ if($_POST['email_address'] != $_POST['email_address2']){ $error = true; $errors .= "Email addresses do not match!\n\n"; $email_error = true; } } /* // If both passwords were posted, validate they match. if($password_error == false){ if($_POST['password'] != $_POST['password2']){ $error = true; $errors .= "Passwords do not match!\n\n"; $password_error = true; } } if($email_error == false){ // Verify if email address has been used already. $ecount = mysql_result(mysql_query("SELECT COUNT(*) AS ecount FROM members WHERE email_address = '{$_POST['email_address']}'"),0); // If email exists, generate error and message. if($ecount > 0){ $error = true; $errors .= "This email address has already ". "been used ". "please choose another.\n\n"; } } // Verify if username already exists. $ucount = mysql_result(mysql_query("SELECT COUNT(*) AS ucount FROM members WHERE username = '{$_POST['username']}'"),0); // If username exists, generate error and message. if($ucount > 0){ $error = true; $errors .= "Username already exists, ". "please choose another.\n\n"; } // If $error is TRUE, then include the signup form // and display the errors we found. */ if($error == true){ $errors = nl2br($errors); include $_SERVER['DOCUMENT_ROOT']. '/sign_up.html'; footer(); exit(); } $user="root"; $host="localhost"; $password=""; $database="venudatabase"; $cxn = mysqli_connect($host,$user,$password,$database) or die ("couldn't connect to the database"); // All checks have passed, insert user in database $sql = "UPDATE venue SET name='$_POST['venu_name']', address1='$_POST['address']', city='$_POST['city'], postcode='$_POST['postcode']', telephone='$_POST['telephone']', fax='$_POST['fax']', email='$_POST['email']', contactname='$_POST['contactname']' WHERE venueid='$_POST['$result3']'"; $result = mysqli_query($cxn,$sql) or die ("NO"); if($result == true) { myheader("Thanks"); include $_SERVER['DOCUMENT_ROOT']. '/thanks.html'; footer(); } // All checks have passed, insert user in database // Email user // Email Admin // That's it! Done! break; default: $myheader("Welcome"); include $_SERVER['DOCUMENT_ROOT']. '/sign_up.html'; $footer(); break; } ?> Help.... Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 3, 2007 Share Posted November 3, 2007 Change <?php // All checks have passed, insert user in database $sql = "UPDATE venue SET name='$_POST['venu_name']', address1='$_POST['address']', city='$_POST['city'], postcode='$_POST['postcode']', telephone='$_POST['telephone']', fax='$_POST['fax']', email='$_POST['email']', contactname='$_POST['contactname']' WHERE venueid='$_POST['$result3']'"; ?> To <?php // All checks have passed, insert user in database $sql = " UPDATE venue SET name='".$_POST['venu_name']."', address1='".$_POST['address']."', city='".$_POST['city']."', postcode='".$_POST['postcode']."', telephone='".$_POST['telephone']."', fax='".$_POST['fax']."', email='".$_POST['email']."', contactname='".$_POST['contactname']."' WHERE venueid='".$_POST['$result3']."'"; ?> Quote Link to comment Share on other sites More sharing options...
abch624 Posted November 3, 2007 Author Share Posted November 3, 2007 Change <?php // All checks have passed, insert user in database $sql = "UPDATE venue SET name='$_POST['venu_name']', address1='$_POST['address']', city='$_POST['city'], postcode='$_POST['postcode']', telephone='$_POST['telephone']', fax='$_POST['fax']', email='$_POST['email']', contactname='$_POST['contactname']' WHERE venueid='$_POST['$result3']'"; ?> To <?php // All checks have passed, insert user in database $sql = " UPDATE venue SET name='".$_POST['venu_name']."', address1='".$_POST['address']."', city='".$_POST['city']."', postcode='".$_POST['postcode']."', telephone='".$_POST['telephone']."', fax='".$_POST['fax']."', email='".$_POST['email']."', contactname='".$_POST['contactname']."' WHERE venueid='".$_POST['$result3']."'"; ?> Perfect!!! Thanks m8 working now, I missed out a "..... Thanks Quote Link to comment Share on other sites More sharing options...
marcus Posted November 3, 2007 Share Posted November 3, 2007 You could just put curly braces around the variables. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.