Click here to Skip to main content
16,017,788 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello,
I am trying to update a table with PHP the problem s the query i write is working perfect with phpmyadmin interface and not with php file please can someone take a look at my this query ??

PHP
$sql = "UPDATE pages SET page_name ='$page_name', page_title ='$page_title', page_desc ='$page_desc', page_content ='$page_content' WHERE page_id =".$id;
Posted
Updated 23-Dec-13 0:06am
v2

Hi,
I found my solution and sharing it for others.
If you are using TinyMCE and sending data for process to a string variable on your PHP Process page you should use mysql_real_escape_string() because their can be Apostrophes in your data and SQL will return error.
i used it as
$page_content = mysql_real_escape_string($_POST['page_content']);
 
Share this answer
 
hi..

you code is

$sql = "UPDATE pages SET page_name ='$page_name', page_title ='$page_title', page_desc ='$page_desc', page_content ='$page_content' WHERE page_id =".$id;

it should be
$sql = "UPDATE pages SET page_name ='$page_name', page_title ='$page_title', page_desc ='$page_desc', page_content ='$page_content' WHERE page_id =.$id";

if id is not fixed you should write

page_id="+.$id+";
 
Share this answer
 
Comments
Mian Shahzad Raza 23-Dec-13 5:17am    
Still same error, 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 's standard dummy text ever since the 1500s, when an unknown printer took a galle' at line 1

i am working on local XAMPP
Mian Shahzad Raza 23-Dec-13 5:21am    
and for addition i am using tinymce, page_content data is coming from tinymce

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900