| | |
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 |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube






but there is no error 