redpedia Posted May 15, 2008 Share Posted May 15, 2008 <? include "config.php"; $id = $_GET['id']; $query_update=mysql_query("UPDATE article SET article_name='$article_name', article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE id='$id'") or die("can't update"); ?> hi i think there is no erorr in code , but it doesn't update or make anything .. where is the problem please ? Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/ Share on other sites More sharing options...
redarrow Posted May 15, 2008 Share Posted May 15, 2008 Try this please.......... <?php include "config.php"; $id = $_GET['id']; $id=mysql_real_escape_string($_POST['id']); $article_name=mysql_real_escape_sting($_POST['article_name']); $article_author=mysql_real_escape_string($_POST['article_author']); $article_date=mysql_real_escape_string($_POST['article_date']); $article_post=mysql_real_escape_string($_POST['article_post']); $query_update="UPDATE article SET article_name='$article_name', article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE id='$id'"; $result=mysql_query($query_update)or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541605 Share on other sites More sharing options...
redpedia Posted May 15, 2008 Author Share Posted May 15, 2008 sorry but it didn't work ... can you please simplify the code ! , i am still newbie Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541610 Share on other sites More sharing options...
redarrow Posted May 15, 2008 Share Posted May 15, 2008 please print back what ur browser sees please........ try this should echo update query statement i think it wrong <?php include "config.php"; $id = $_GET['id']; $id=mysql_real_escape_string($_POST['id']); $article_name=mysql_real_escape_sting($_POST['article_name']); $article_author=mysql_real_escape_string($_POST['article_author']); $article_date=mysql_real_escape_string($_POST['article_date']); $article_post=mysql_real_escape_string($_POST['article_post']); $query_update="UPDATE article SET article_name='$article_name', article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE id='$id'"; echo $query; $result=mysql_query($query_update)or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541611 Share on other sites More sharing options...
redpedia Posted May 15, 2008 Author Share Posted May 15, 2008 Fatal error: Call to undefined function mysql_real_escape_sting() in C:\AppServ\www\news\update_article_action.php on line 22 Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541617 Share on other sites More sharing options...
redarrow Posted May 15, 2008 Share Posted May 15, 2008 sorry try agin forgot a r lol <?php include "config.php"; $id = $_GET['id']; $id=mysql_real_escape_string($_POST['id']); $article_name=mysql_real_escape_string($_POST['article_name']); $article_author=mysql_real_escape_string($_POST['article_author']); $article_date=mysql_real_escape_string($_POST['article_date']); $article_post=mysql_real_escape_string($_POST['article_post']); $query_update="UPDATE article SET article_name='$article_name', article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE id='$id'"; echo $query; $result=mysql_query($query_update)or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541619 Share on other sites More sharing options...
redpedia Posted May 15, 2008 Author Share Posted May 15, 2008 i've found a bug , its n't id , its article_id ??? even this .. your code didn't show any erorr , but still didn't update the records <?php include "config.php"; //$id = $_GET['id']; $id=mysql_real_escape_string($_POST['article_id']); $article_name=mysql_real_escape_string($_POST['article_name']); $article_author=mysql_real_escape_string($_POST['article_author']); $article_date=mysql_real_escape_string($_POST['article_date']); $article_post=mysql_real_escape_string($_POST['article_post']); $query_update="UPDATE article SET article_name='$article_name', article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE article_id='$id'"; echo $query; $result=mysql_query($query_update)or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541622 Share on other sites More sharing options...
redarrow Posted May 15, 2008 Share Posted May 15, 2008 <?php include "config.php"; //$id = $_GET['id']; $id=mysql_real_escape_string($_POST['article_id']); $article_name=mysql_real_escape_string($_POST['article_name']); $article_author=mysql_real_escape_string($_POST['article_author']); $article_date=mysql_real_escape_string($_POST['article_date']); $article_post=mysql_real_escape_string($_POST['article_post']); $query_update="UPDATE article SET article_name='$article_name', article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE article_id='$id'"; echo $query_update; $result=mysql_query($query_update)or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541625 Share on other sites More sharing options...
redpedia Posted May 15, 2008 Author Share Posted May 15, 2008 didn't work also ... any thank you very much for your help , i troubled you enough Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541631 Share on other sites More sharing options...
AndyB Posted May 15, 2008 Share Posted May 15, 2008 Please post exactly what is generated by the echo $query_update; statement. Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541642 Share on other sites More sharing options...
redpedia Posted May 15, 2008 Author Share Posted May 15, 2008 <?php UPDATE article SET article_name='cnn around the world', article_author='tom',article_date='2008-05-12', article_post='er' WHERE article_id='' ?> i notice that it didn't dedicate the article_id value Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541645 Share on other sites More sharing options...
redpedia Posted May 15, 2008 Author Share Posted May 15, 2008 is this really hard ?! Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541792 Share on other sites More sharing options...
revraz Posted May 15, 2008 Share Posted May 15, 2008 Not really, but you need to figure out why your $id isn't set. is this really hard ?! Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541813 Share on other sites More sharing options...
redpedia Posted May 15, 2008 Author Share Posted May 15, 2008 can the post or get be the reason, i mean i use form with post ! Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541854 Share on other sites More sharing options...
revraz Posted May 15, 2008 Share Posted May 15, 2008 Hard to say, you don't show your FORM code. Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-541871 Share on other sites More sharing options...
AndyB Posted May 15, 2008 Share Posted May 15, 2008 If you want help, then can you cooperate please. If you post the actual query string generated by your code it will speed up solving what should be a trivial problem. echo $query_update; is the magic line (which was recommended to you) that will display the query on your screen. Link to comment https://forums.phpfreaks.com/topic/105710-problem-with-update-syntax/#findComment-542503 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.