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 ? Quote Link to comment 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()); ?> Quote Link to comment 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 Quote Link to comment 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()); ?> Quote Link to comment 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 Quote Link to comment 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()); ?> Quote Link to comment 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()); ?> Quote Link to comment 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()); ?> Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
redpedia Posted May 15, 2008 Author Share Posted May 15, 2008 is this really hard ?! Quote Link to comment 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 ?! Quote Link to comment 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 ! Quote Link to comment 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. Quote Link to comment 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. 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.