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

 

Link to comment
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

 

I didn't get any errors. :/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.