[PHP-DB] INSERT question. 2 pointers.
hi Scott, 1. When you are using an insert where you dont want to use all columns: use this: $query = INSERT INTO accounts VALUES('.$accnts[0].', 'TIMESTAMP(10)','','','','',); (never have empty comma strings with nothing inside.) 2. Secondly, when you get errors, and you dont know where the error is do this: before executing the query, print out the query on the browser (comment out the query execution code) and then copy paste the query from the browser and then run the same in your mysql client, and you will know exactly where is the problem from the error generated. regards, *** Amit Wadhwa Dell International Services *** -Original Message- From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 12:46 AM To: '[EMAIL PROTECTED]' Subject: [PHP-DB] INSERT question... I have an INSERT statement that I cannot quiet get working. The table that this data is being put into has 7 columns, but I only care about putting in the data from the first two columns at this time. The first column is an array element, and the second column needs to be a timestamp. Here is the INSERT statement: $query = INSERT INTO accounts VALUES('.$accnts[0].', 'TIMESTAMP(10)', , , , ,); Here is the error being displayed on the web page: You have an error in your SQL syntax near ' , , ,)' at line 1 Thanks in advance for the help. Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] LIKE statement or IN statement?
if you want to search for multiple words, u have to use multiple like operators: select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; or the IN statement with wildcards: select count(distinct itemid) from business where name IN ('%word1%','%word2%','%word3%'); -- im not too sure of this, would the experts please shed some more light on this one if its correct? Amit On 4 Nov 2002, Chris Barnes wrote: Hi, I've got a dilly of a problem. I'm probably doing something wrong but I don't know what. I'm trying to use the LIKE statement in a query where more than one word is used in with LIKE..e.g. select count(distinct itemid) from business where name or description like 'word1 word2 word3%' The problem I'm having is probably obvious to you but I don't know why this returns no matches but if i specify only 1 word in the LIKE statement then it returns a match. Am i not able to specify more than 1 word with LIKE or am I just doing it wrong? It has been designed to take input from a web form by the variable $search_string and then the query string is constructed from that e.g. $query = select count(distinct itemid) from business where name or description like' . $search_string . '; Any help or suggestions greatly appreciated. --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] LIKE statement or IN statement?
ok so you would have to use : --select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; no other go. .. You can't use wildcards with IN, only with LIKE or regular expressions. ---John Holmes... -Original Message- From: [EMAIL PROTECTED] [mailto:Amit_Wadhwa;Dell.com] Sent: Sunday, November 03, 2002 5:31 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] LIKE statement or IN statement? if you want to search for multiple words, u have to use multiple like operators: select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; or the IN statement with wildcards: select count(distinct itemid) from business where name IN ('%word1%','%word2%','%word3%'); -- im not too sure of this, would the experts please shed some more light on this one if its correct? Amit On 4 Nov 2002, Chris Barnes wrote: Hi, I've got a dilly of a problem. I'm probably doing something wrong but I don't know what. I'm trying to use the LIKE statement in a query where more than one word is used in with LIKE..e.g. select count(distinct itemid) from business where name or description like 'word1 word2 word3%' The problem I'm having is probably obvious to you but I don't know why this returns no matches but if i specify only 1 word in the LIKE statement then it returns a match. Am i not able to specify more than 1 word with LIKE or am I just doing it wrong? It has been designed to take input from a web form by the variable $search_string and then the query string is constructed from that e.g. $query = select count(distinct itemid) from business where name or description like' . $search_string . '; Any help or suggestions greatly appreciated. --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php