Hi, how can I resolve this mysql error? I dont understand this. 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 't compromise on their uptime performance over the net. Moreover they are ' at line 1 Any idea? Thanks!
It looks like the content your trying to load has apostrophes ' so and quick solution is to use addslashes() see the example below the surname O'Reilly <?php $str = "Is your name O'reilly?"; echo addslashes($str); // Outputs: Is your name O\'reilly? ?> PHP: In order for use to help your further please post your mysql query
this is mysql query <?php $id=$_POST['id']; $cat1=$_POST['articlenumber']; $cat2=$_POST['articletitle']; $description=$_POST['description']; $file='rajesh.txt'; if(!file_exists($file)){ die("There is no file"); } $fhh=fopen($file,'w') or die('Could not open file'); fwrite($fhh,$description) or die('Could not write to file'); $data=file_get_contents($file); include('connection.php'); $query="SELECT * FROM businessarticles WHERE id='$id'"; $result=mysql_query($query) or die('query failed'); $row=mysql_fetch_array($result); $query1="UPDATE businessarticles SET articlenumber='$cat1', articletitle='$cat2', articlebody='$data' WHERE id='$id'"; mysql_query($query1) or die(mysql_error()); echo "<center>"."Entry successfully updated"."</center>"; ?>
Might need tweaking $query1="UPDATE businessarticles SET articlenumber='$cat1', articletitle='" . addslashes($cat2). "', articlebody='" . addslashes($data). "' WHERE id='$id'"; Code (markup):
Just FYI, you should really use mysql_real_escape_string rather than addslashes for security and safety.
it's better to use mysql_real_escape_string rather than addslashes.. <?php $id=mysql_real_escape_string($_POST['id']); ... PHP:
We'll probably need more of your SQL query to help you there. EDIT: Seems others answered before I submitted my post. :/