Jump to content

Simple database update issue


Shadowing

Recommended Posts

I cant figure out why im having this problem.

i stuck this at the top of my page on its own and it wont update the row to read

 

 <?php
mysql_query("UPDATE pm SET read= 'read' WHERE pm_id = '".mysql_real_escape_string($_GET['pm_id'])."'");
?> 

 

I echo $_GET['pm_id']; and that turn out correct and the number matches the pm_id on the row.

everything is lowercase

I typed read manually into the column and echo that and it showed read

also I have this same exact line of code on another script that works fine.

 

does someone see something im over looking? this is driving me crazy :)

 

 

http://localhost/stargate/users/view.php?pm_id=1376672&inbox=2

 

 <?php require("menu.php"); ?>

<html>
<body>
  

<?php
mysql_query("UPDATE pm SET read= 'read' WHERE pm_id = '".mysql_real_escape_string($_GET['pm_id'])."'");

?>



</body>
</html> 

Link to comment
Share on other sites

yah i know its not case sensitive but mention it anyways lol

 

added more details in my first post

 

I even tried

 

 <?php mysql_query("UPDATE pm SET read= 'read'"); ?> 

 

that should make every row set to read right?

 

the column is set to length of 6 and type VARCHAR

Link to comment
Share on other sites

Stop embedding the query string in the query execution. Form it in a variable, then use the variable to execute the query so you can echo the query string when things like this happen. Check to make sure the query executes successfully and if not, echo the query string and mysql_error(). Post any errors returned by MySQL.

 

$query = "SELECT field FROM table";
if( $result = mysql_query($query) ) {
     // do whatever you need to do for a successful query execution
} else {
     echo "<br>Query: $query<br>Produced error: " . mysql_error() . '<br>';
}

Link to comment
Share on other sites

yah i need to start debugging more. this will help me out alot in the future

 

Query: UPDATE pm SET read= 'read' WHERE pm_id = '1376672'

Produced error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read= 'read' WHERE pm_id = '1376672'' at line 1

 

 <?php 
$query = ("UPDATE pm SET read= 'read' WHERE pm_id = '".mysql_real_escape_string($_GET['pm_id'])."'");
			if( $result = mysql_query($query) ) {


} else {     

                                    echo "<br>Query: $query<br>Produced error: " . mysql_error() . '<br>';} ?> 

wierd

 

i have this code in another script that works fine

 

 <?php mysql_query("UPDATE users SET monitor= 'mod' WHERE goauld = '".mysql_real_escape_string($_POST['add_mod'])."'");
?> 

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.