franknu Posted May 30, 2007 Share Posted May 30, 2007 Ok I am getting a parser error updating a database If i have the variables to display like this Slogan2 = ('$_POST[slogan2]'), it actually works but when i hit the back bottom on the browser it deletes all the info from the database except for user name and password but they are actually set up like this ".$_SESSION['Password']." l , i have tried many diffrent way and it keeps givin me that parser error. please help here is my database <? $query="UPDATE business_info SET `BusinessName`=('$_POST['BusinessName']'),`Slogan`=('$_POST['Slogan']'), `Business_Address` =($_POST['Business_Address']),`Tel`=($_POST['Tel']),`Website`=($_POST['Website']), Email = ($_POST['Email']), Fax= ('$_POST[Fax]'), `type`='$type', make = '$make', Categories = ('$_POST[Categories]'), Keyword = ('$_POST[Keyword]'), Headline = ('$_POST[Headline]'), Slogan2 = ('$_POST[slogan2]'), Description1 = ('$_POST[Description1]'), Description2 = ('$_POST[Description2]'), Description3 = ('$_POST[Description3]'), User_Name='".$_SESSION['User_Name']."' WHERE Password='".$_SESSION['Password']."'"; $result = mysql_query($query) or die ("Problem with the query: <pre>$query</pre><br>" . mysql_error()); echo"$query"; ?> this is my error display; Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/townsfin/public_html/authorization/text_update.php on line 114 Quote Link to comment https://forums.phpfreaks.com/topic/53571-parser-error-updating-database/ Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 Wow, go back and read proper php syntax for a string. You use like 10 different ways there and the ONLY correct one is the username part. <?php $query="UPDATE business_info SET `BusinessName`='" . $_POST['BusinessName'] . "',`Slogan`='" . $_POST['Slogan'] . "', `Business_Address` ='".$_POST['Business_Address']."',`Tel`='".$_POST['Tel']."',`Website`='" . $_POST['Website'] . "', Email = '".$_POST['Email']."', Fax= '".$_POST[Fax]."', `type`='$type', make = '$make', Categories = '".$_POST[Categories]."', Keyword = '".$_POST[Keyword]."', Headline = '".$_POST['Headline']."', Slogan2 = '".$_POST['Slogan2']."', Description1 = '".$_POST['Description1']."', Description2 = '".$_POST['Description2']."', Description3 = '".$_POST[Description3]."', User_Name='".$_SESSION['User_Name']."' WHERE Password='".$_SESSION['Password']."'"; ?> That was flawed with PHP errors IE using the array inside the string like it did not require anything extra. Mysql was flawed with the ( ) and not encapsulating half the data in single quotes ' ' Really man you need to read up on SQL and PHP syntax. That was the worst written out query I have ever seen. Quote Link to comment https://forums.phpfreaks.com/topic/53571-parser-error-updating-database/#findComment-264793 Share on other sites More sharing options...
franknu Posted May 30, 2007 Author Share Posted May 30, 2007 Ok, Now i dont have the PArser error but again, if i made changes and hit the back bottom on the browser to go back all the data gets delete from the database any peace of advise on this case Quote Link to comment https://forums.phpfreaks.com/topic/53571-parser-error-updating-database/#findComment-264826 Share on other sites More sharing options...
trq Posted May 30, 2007 Share Posted May 30, 2007 any peace of advise on this case Wrap your query in an if() so it is only executed when it has been posted to by the form. eg; <?php if (isset($_POST['submit'])) { // run query } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53571-parser-error-updating-database/#findComment-264832 Share on other sites More sharing options...
franknu Posted May 30, 2007 Author Share Posted May 30, 2007 thank u that did it, i cant believe i didn't think of that thank u Quote Link to comment https://forums.phpfreaks.com/topic/53571-parser-error-updating-database/#findComment-264863 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.