franknu Posted March 29, 2007 Share Posted March 29, 2007 ok i have this code to update the database the problem is that my sql is not working for some odd reason maybe because it is inside an php script here is my code if ($num_rows!=1) { print "<p><b>username and/or password not found. Try again?</b></p>"; } else { echo " Welcome"; echo' <table border="0"> <tr> <td valign="top"> <table border="0"> <tr> <td bgcolor="cococo"> <a href="index.php"> Home <font color="cococo">ddddddddddddddddddddd</font> </a> </td> </tr> <tr> <td> welcome $BusinessName, <font color="ffffff">dddddddddddddddddddfffffffffffffffffffdd</font> </td> </tr> </table> <table background="../images/fondo2.jpg" border="1" valign="top"> <tr> <td valign="top"> <table border="1" background="../images/fondo2.jpg" valign="top"> <tr> <td> <a href= "http://entrepreneur.com">Pictures Uploads/change</a> </td> </tr> <tr> <td> <a href= "http://entrepreneur.com">Advertise your website</a> </td> </tr> <tr> <td> </td> </tr> <tr> <td> <a href="http://69.89.27.201:2082/horde/index.php/">Email</a> </td> </tr> <tr> <td> </td> </tr> <tr> <td> <a href="http://www.nasdaq.com">Stock Market</a> </td> </tr> </table> </td> <td valign="top"> <center><table border="1"> <tr> <td> <a href=\"update.php?update=true\">update</a> </td> <td> <a href=\"keyword.php?keyword=true\">Add Key words</a> </td> <td> <a href="http://www.ccbill.com">CCBILL</a> </td> </tr> </table> </center> // display codes $sql = "SELECT * FROM business_info WHERE `BusinessName`= "$BusinessName" AND `User_Name`="$User_Name""; $result = mysql_query($query) or die (mysql_error()); $res2 = mysql_fetch_assoc($result); $BusinessName if(isset($_POST["submit"])) { $query="UPDATE business_info SET `BusinessName`= "{$BusinessName}", `Slogan`="{$Slogan}", `Business_Address`="{$Business_Address}", `Tel`="{$Tel}", `Website`="{$Website}", `Email`="{$Email}", `Fax`="{$Fax}", `type`="{$type}", `make`="{$make}", `Categories`="{$Categories}", `Keyword`="{$Keyword}", `Picture1`="{$Picture1}", `Headline`="{$Headline}", `Slogan2`="{$Slogan2}", `Description1`="{$Description1}", `Description2`="{$Description2}", `Description3`= "{$Description3}", `Picture2`="{$Picture2}", `Picture3`="{$Picture3}", `Password`="{$Password}" WHERE `User_Name`="{$User_Name}""; $result = mysql_query($query) or die (mysql_error()); } <table bgcolor="ffffff"> <tr> <td> <table> <tr> </tr> </table> </td> </tr> <tr> <td></td> </tr> <tr> <td> <table> <tr> <td> <table bgcolor="ffffff "> <tr> <td> <table> <form action="<?php echo $_SERVER["PHP_SELF"] method="Post" ?>";> <tr> <td> Busiess Info </td> </tr> <tr> <td> <table> <tr> <td> Business Name </td> <td> <input type="text" name="BusinessName" Value="$BusinessName"> </td> </tr> <tr> <td> Slogan </td> <td> <input type="text" NAME="Slogan" value="$Slogan"> </td> <td> Website </td> <td> <input type="text" name="Website" value="$Website"> </td> </tr> <tr> here is my display $sql = "SELECT * FROM business_info WHERE `BusinessName`= "$BusinessName" AND `User_Name`="$User_Name""; $result = mysql_query($query) or die (mysql_error()); $res2 = mysql_fetch_assoc($result); $BusinessName if(isset($_POST["submit"])) { $query="UPDATE business_info SET `BusinessName`= "{$BusinessName}", `Slogan`="{$Slogan}", `Business_Address`="{$Business_Address}", `Tel`="{$Tel}", `Website`="{$Website}", `Email`="{$Email}", `Fax`="{$Fax}", `type`="{$type}", `make`="{$make}", `Categories`="{$Categories}", `Keyword`="{$Keyword}", `Picture1`="{$Picture1}", `Headline`="{$Headline}", `Slogan2`="{$Slogan2}", `Description1`="{$Description1}", `Description2`="{$Description2}", `Description3`= "{$Description3}", `Picture2`="{$Picture2}", `Picture3`="{$Picture3}", `Password`="{$Password}" WHERE `User_Name`="{$User_Name}""; $result = mysql_query($query) or die (mysql_error()); } ";> also on the values for all i get is $VARIABLE please help Quote Link to comment Share on other sites More sharing options...
interpim Posted March 29, 2007 Share Posted March 29, 2007 your echo before all the html... change it from echo' to echo ' note the space. Quote Link to comment Share on other sites More sharing options...
per1os Posted March 29, 2007 Share Posted March 29, 2007 Your using double quotes in your SQL query, MySQL does not like double quotes around the values, they MUST be single quotes. Not to mention you did not even bother to escape the double quotes but either way that is why the sql is failing. Quote Link to comment Share on other sites More sharing options...
franknu Posted March 29, 2007 Author Share Posted March 29, 2007 well actually if i add only single quotes it gives me a parser error, also the echo' and echo ' doesnt make any diffrent Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 29, 2007 Share Posted March 29, 2007 You have quote problems all over your code. Change the first query to: <?php $sql = "SELECT * FROM business_info WHERE BusinessName = '$BusinessName' AND User_Name = '$User_Name'"; $result = mysql_query($query) or die ("Problem with the query: <pre>$sql</pre><br>" . mysql_error()); ?> And the second to: <?php $query="UPDATE business_info SET BusinessName= '$BusinessName', `Slogan`='$Slogan', Business_Address = '$Business_Address', Tel='$Tel', Website= '$Website', Email = '$Email', Fax= '$Fax', `type`='$type', make = '$make', Categories = '$Categories', Keyword = '$Keyword', Picture1 = '$Picture1', Headline = '$Headline', Slogan2 = '$Slogan2', Description1 = '$Description1', Description2 = '$Description2', Description3 = '$Description3', Picture2 = '$Picture2', Picture3 = '$Picture3', `Password`= '$Password' WHERE User_Name = '$User_Name'"; $result = mysql_query($query) or die ("Problem with the query: <pre>$query</pre><br>" . mysql_error()); ?> You only have to use the backticks when the name will confict with a MySQL reserved word. Ken 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.