hinchcliffe Posted November 14, 2007 Share Posted November 14, 2007 Hey guys can you take a look over my code my update query isn't working. Ty $update = "UPDATE articles SET title = '".$_POST['title']."', body = '".$_POST['body']."' WHERE id ='".$_GET['idr']."'"; $check = mysql_query($update); echo "<div><center>Success! Job Saved!</center></div>"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=\"index.php\">"; Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 14, 2007 Share Posted November 14, 2007 Change your code to this and tell us what it gives you <?php $update = "UPDATE articles SET title = '".$_POST['title']."', body = '".$_POST['body']."' WHERE id ='".$_GET['idr']."'"; $check = mysql_query($update)or die("ERROR - ". mysql_error() ."<br>" . $update); ?> Quote Link to comment Share on other sites More sharing options...
hinchcliffe Posted November 14, 2007 Author Share Posted November 14, 2007 weird still not updating, there are no errors in the code though. hmm Maybe take a look at more of my code. <?php // if the submit button is clicked, do this. if($_POST['update']) { $table = $_POST['table']; $returnurl1 = "find_articles.php"; // this is the redirect url after succes $returnurl2 = "edit_articles.php?id=".$_GET['idr']."&mode=modify"; // this is the redirect url after success if($_GET['mode']=='add') { $insert = "INSERT INTO articles (title, body) VALUES ('".$_POST['title']."', '".$_POST['body']."')"; mysql_query($insert); // redirect after 2 seconds echo "<div><center>Success! Article Added!</center></div>"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=".$returnurl1."\">"; } //if mod eis not add, then the mode is modify else { $update = "UPDATE articles SET title = '".$_POST['title']."', body = '".$_POST['body']."' WHERE id ='".$_GET['idr']."'"; $check = mysql_query($update); echo "<div><center>Success! Job Saved!</center></div>"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=\"index.php\">"; } } ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 14, 2007 Share Posted November 14, 2007 Use this code and copy and paste anything you see on the screen <?php // if the submit button is clicked, do this. if ($_POST['update']) { $table = $_POST['table']; $returnurl1 = "find_articles.php"; // this is the redirect url after succes $returnurl2 = "edit_articles.php?id=".$_GET['idr']."&mode=modify"; // this is the redirect url after success if ($_GET['mode']=='add') { $insert = "INSERT INTO articles (title, body) VALUES ('".$_POST['title']."', '".$_POST['body']."')"; mysql_query($insert); // redirect after 2 seconds echo "<div><center>Success! Article Added!</center></div>"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=".$returnurl1."\">"; } //if mod eis not add, then the mode is modify else { echo "This line should show up...<p>"; $update = "UPDATE articles SET title = '".$_POST['title']."', body = '".$_POST['body']."' WHERE id ='".$_GET['idr']."'"; $check = mysql_query($update)or die("ERROR - ". mysql_error() ."<br>" . $update); echo $update.'<p>'; echo "<div><center>Success! Job Saved!</center></div>"; //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=\"index.php\">"; } } ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted November 14, 2007 Share Posted November 14, 2007 He is adding DIE statements in your code so it will give you an Error, and then you can post the Error. weird still not updating, there are no errors in the code though. hmm Maybe take a look at more of my code. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 14, 2007 Share Posted November 14, 2007 <?php // if the submit button is clicked, do this. if ($_POST['update']) { $table = $_POST['table']; $returnurl1 = "find_articles.php"; // this is the redirect url after succes $returnurl2 = "edit_articles.php?id=".$_GET['idr']."&mode=modify"; // this is the redirect url after success if ($_GET['mode']=='add') { $insert = 'INSERT INTO articles (title, body) VALUES ('{.$_POST['title'].}', '{.$_POST['body'].}')'; mysql_query($insert); // redirect after 2 seconds echo "<div><center>Success! Article Added!</center></div>"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=".$returnurl1."\">"; } //if mod eis not add, then the mode is modify else { echo "This line should show up...<p>"; $update = 'UPDATE articles SET title = '{.$_POST['title'].}', body = '{.$_POST['body'].}' WHERE id ='{.$_GET['idr'].}''; $check = mysql_query($update)or die("ERROR - ". mysql_error() ."<br>" . $update); echo $update.'<p>'; echo "<div><center>Success! Job Saved!</center></div>"; //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=\"index.php\">"; } } ?> try using single quotes and curly brackets around your Super Global Variables like post and get 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.