stud91
stud91

Reputation: 1854

Updating SQL using PHP - Error

Right so i have php code to update a SQL table. If i replace $_GET['emailID'] with a number say 1 the database IS updated. But otherwise no update. What seems to be wrong here

Table: emails

Fields: mailbox, emailID

$query = 'UPDATE `emails` SET `mailbox`=\'trash\' WHERE `emailID`='.(int)$_GET['emailID'];

Upvotes: 0

Views: 78

Answers (4)

Bhaskar Bhatt
Bhaskar Bhatt

Reputation: 1473

$query = "UPDATE `emails` SET `mailbox`='trash' WHERE `emailID`= ".$_GET['emailID'];

Try this one sure it will work

Upvotes: 0

plusodinminus
plusodinminus

Reputation: 1

Value of attribut must be selected by single quotes. Try this:

$query = "UPDATE `emails` SET `mailbox` = 'trash' WHERE `emailID` = '" . intval($_GET['emailID']) . "'";

Upvotes: 0

Krish R
Krish R

Reputation: 22741

Can you try this,

 $query = 'UPDATE `emails` SET `mailbox`=\'trash\' WHERE `emailID`="'.(int)$_GET['emailID'].'" ';

Upvotes: 1

Do like this

$query = "UPDATE `emails` SET `mailbox`='trash' WHERE `emailID`=".intval($_GET['emailID']);

Upvotes: 1

Related Questions