Re: MySQL query problems...
| From: | Frank M Flynn | Date: | Thu, 24 Mar 2005 19:57:25 +0000 |
| Subject: | Re: MySQL query problems... | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-39033@lists.php.net to get a copy of this message | ||
The error message and when I have problems I find it's very helpful to print the actual value of the $query variable.
In your case it looks like
AND acct_db.key1 LIKE \"%\".AllMid_Data.CPU_Hostnameis adding AND acct_db.key1 LIKE "%".AllMid_Data.CPU_Hostname and you can't join two strings in SQL with a '.' like you can in PHP you should use a + for the two strings. I think what you want is:
AND acct_db.key1 LIKE \"%\" + AllMid_Data.CPU_HostnameGood Luck, Frank On Mar 24, 2005, at 1:33 AM, php-db-digest-help@lists.php.net wrote:
From: "NIPP, SCOTT V \(SBCSI\)" <sn4265@sbc.com> Date: March 23, 2005 3:18:44 PM PST To: <php-db@lists.php.net> Subject: MySQL query problems... I am getting errors for the following queries. This query seems to work fine in phpMyAdmin. $query2 = "SELECT AllMid_Data.CPU_Hostname FROM AllMid_Data, accounts WHERE AllMid_Data.CPU_IN_SVC = \"Y\" AND AllMid_Data.CPU_DNS = \"sbcld.sbc.com\" AND accounts.sbcuid = $sbcuid AND accounts.system = AllMid_Data.CPU_Hostname AND accounts.ctime IS NULL ORDER BY CPU_Hostname ASC"; $results2 = mysql_query($query2, $Prod) or die(mysql_error()); $system2 = mysql_fetch_assoc($results2); $query3 = "SELECT AllMid_Data.CPU_Hostname FROM AllMid_Data, acct_db WHERE AllMid_Data.CPU_IN_SVC = \"Y\" AND AllMid_Data.CPU_DNS = \"sbcld.sbc.com\" AND acct_db.key1 LIKE \"$sbcuid%\" AND acct_db.key1 LIKE \"%\".AllMid_Data.CPU_Hostname ORDER BY CPU_Hostname ASC"; $results3 = mysql_query($query3, $Prod) or die(mysql_error()); $system3 = mysql_fetch_assoc($results3); I am assuming that I have an issue with query3. Thanks in advance. Scott Nipp Phone: (214) 858-1289 E-mail: sn4265@sbc.com Web: http:\\ldsa.sbcld.sbc.com