| | |
simple mysql question..plz answer :)
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Ok so what i'd like to know is how to have two where statements in a mysql delete query. I get an error if i do this:
Any help would be much appreciated, I know this is a silly question, but i havnt done any php programming for a couple of months and need to get back into it!
Thanks,
jakx12
mysql_query("DELETE FROM user_notifications WHERE username='$acc' AND WHERE notification='$note2'")
or die(mysql_error());Any help would be much appreciated, I know this is a silly question, but i havnt done any php programming for a couple of months and need to get back into it!
Thanks,
jakx12
mysql_query("DELETE FROM user_notifications WHERE username='".$acc."' AND notification='".$note2."' "); that should be fine. if its not, try checking your $acc and $note2 variables...
Last edited by peter_budo; Mar 1st, 2009 at 6:27 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Ill solve somebody's thread someday! xD
•
•
•
•
mysql_query("DELETE FROM user_notifications WHERE username='".$acc."' AND notification='".$note2."' ");
that should be fine. if its not, try checking your $acc and $note2 variables...
php Syntax (Toggle Plain Text)
mysql_query("DELETE FROM `user_notifications` WHERE `username`='".mysql_real_escape_string($acc)."' AND `notification`='".mysql_real_escape_string($note2)."' ") or die(mysql_error());
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Apr 2008
Posts: 28
Reputation:
Solved Threads: 3
To be a better php programmer always use single quotes like this,
bcoz: php parser will search and parse full string while using double quotes.
- might look simple - but usefull tip(i think so)
php Syntax (Toggle Plain Text)
mysql_query('DELETE FROM user_notifications WHERE username="'.mysql_real_escape_string($acc).'" AND notification="'.mysql_real_escape_string($note2).'"') or die(mysql_error());
- might look simple - but usefull tip(i think so) Last edited by peter_budo; Mar 8th, 2009 at 6:41 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
•
•
To be a better php programmer always use single quotes like this,
mysql_query('DELETE FROM user_notifications WHERE username="'.mysql_real_escape_string($acc).'" AND notification="'.mysql_real_escape_string($note2).'"')
or die(mysql_error());
bcoz: php parser will search and parse full string while using double quotes.- might look simple - but usefull tip(i think so)
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Apr 2008
Posts: 28
Reputation:
Solved Threads: 3
while using double quotes.. parser will search for php variable("my name is vinoth" instead use 'my name is vinoth') inside that string...(execution/parsing time will be greater). If we want to display the string with out any php variable('my name is '.$name)... then better to use single quotes...
its truth.... in PHP (I may not know about other languages)
its truth.... in PHP (I may not know about other languages)
•
•
•
•
while using double quotes.. parser will search for php variable("my name is vinoth" instead use 'my name is vinoth') inside that string...(execution/parsing time will be greater). If we want to display the string with out any php variable('my name is '.$name)... then better to use single quotes...
its truth.... in PHP (I may not know about other languages)
php Syntax (Toggle Plain Text)
$var="line1\nline2"; mysql_query('INSERT INTO `table` SET `column`="'.$var.'"');
PHP Syntax (Toggle Plain Text)
line1 line2
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
![]() |
Other Threads in the PHP Forum
- Previous Thread: insert csv file into mysql through php
- Next Thread: Using and processing XML from multiple sources
| Thread Tools | Search this Thread |
advanced alerts apache api archive array autosuggest beginner binary broken cakephp checkbox class clients cms code cron curl database date datepart display dynamic echo email emptydisplayvalue eregi error execute explodefunction file files folder form forms function functions google hack head href htaccess html if...loop image include insert ip javasciptvalidation javascript joomla keywords library limit link login mail matching menu mlm multiple mysql number object oop password paypal pdf php phpincludeissue query radio random recursive remote script search searchbox server sessions shot smarty source space speed sql syntax system table tutorial update upload url validator variable vbulletin video web website youtube






but there is no error 