Jump to content

Why doesn't it updated?


3raser

Recommended Posts

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>
					';

			}

Link to comment
https://forums.phpfreaks.com/topic/211122-why-doesnt-it-updated/
Share on other sites

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

 

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. :/

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.

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.... :/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.