3raser Posted August 18, 2010 Share Posted August 18, 2010 Is there something wrong with this query? elseif($_POST["titlee"] && $_POST["contente"]) { $titlee = $_POST['titlee']; $contente = $_POST['contente']; $to = $_POST['edit']; mysql_query("UPDATE custom_pages SET title='$titlee' AND content='$contente' WHERE id='$to'"); echo '<div class="post"> <div class="postheader"><h1>Updated</h1></div> <div class="postcontent"> <p>Your custom page has been updated.</p> </div> <div class="postfooter"></div> </div> '; } Quote Link to comment https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/ Share on other sites More sharing options...
kenrbnsn Posted August 19, 2010 Share Posted August 19, 2010 You're not checking for errors, so how would you know if it worked or not. Also, you really should use the function mysql_real_escape_string on any user data that will be used with a MySQL database. <?php $titlee = mysql_real_escape_string($_POST['titlee']); $contente = mysql_real_escape_string($_POST['contente']); $to = mysql_real_escape_string($_POST['edit']); $q = "UPDATE custom_pages SET title='$titlee' AND content='$contente' WHERE id='$to'"; $rs = mysql_query($q) or die("Problem with the update query: $q<br>" . mysql_error()); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/#findComment-1101041 Share on other sites More sharing options...
3raser Posted August 19, 2010 Author Share Posted August 19, 2010 You're not checking for errors, so how would you know if it worked or not. Also, you really should use the function mysql_real_escape_string on any user data that will be used with a MySQL database. <?php $titlee = mysql_real_escape_string($_POST['titlee']); $contente = mysql_real_escape_string($_POST['contente']); $to = mysql_real_escape_string($_POST['edit']); $q = "UPDATE custom_pages SET title='$titlee' AND content='$contente' WHERE id='$to'"; $rs = mysql_query($q) or die("Problem with the update query: $q<br>" . mysql_error()); ?> Ken I didn't get any errors. :/ Quote Link to comment https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/#findComment-1101056 Share on other sites More sharing options...
3raser Posted August 20, 2010 Author Share Posted August 20, 2010 Bump... Quote Link to comment https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/#findComment-1101478 Share on other sites More sharing options...
jj20051 Posted August 20, 2010 Share Posted August 20, 2010 Ok what he's saying is that in PHP and MYSQL in order to get errors you have to include a piece of code for it to work. Look at your code: mysql_query("UPDATE custom_pages SET title='$titlee' AND content='$contente' WHERE id='$to'"); If you add "or die(mysql_error());" to it the script will display any errors it comes across. Thus try this: mysql_query("UPDATE custom_pages SET title='$titlee' AND content='$contente' WHERE id='$to'") or die (mysql_error()); and he's right if your getting data from a database you should use mysql_real_escape_string() to prevent mysql injection. Quote Link to comment https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/#findComment-1101486 Share on other sites More sharing options...
3raser Posted August 21, 2010 Author Share Posted August 21, 2010 Ok what he's saying is that in PHP and MYSQL in order to get errors you have to include a piece of code for it to work. Look at your code: mysql_query("UPDATE custom_pages SET title='$titlee' AND content='$contente' WHERE id='$to'"); If you add "or die(mysql_error());" to it the script will display any errors it comes across. Thus try this: mysql_query("UPDATE custom_pages SET title='$titlee' AND content='$contente' WHERE id='$to'") or die (mysql_error()); and he's right if your getting data from a database you should use mysql_real_escape_string() to prevent mysql injection. I didn't get any errors.... :/ Quote Link to comment https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/#findComment-1101965 Share on other sites More sharing options...
kenrbnsn Posted August 21, 2010 Share Posted August 21, 2010 Echo your query before you do the mysql_query() function. Then try your query in phpmyadmin and see what happens. Do some debugging on your own. Maybe you're not even getting to that block of code... Ken Quote Link to comment https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/#findComment-1101969 Share on other sites More sharing options...
jcbones Posted August 21, 2010 Share Posted August 21, 2010 mysql_query("UPDATE custom_pages SET title='$titlee' , content='$contente' WHERE id='$to'") or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/#findComment-1102105 Share on other sites More sharing options...
jj20051 Posted August 25, 2010 Share Posted August 25, 2010 Pretty sure he's Chinese and just doesn't understand us... Quote Link to comment https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/#findComment-1103506 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.