Re: [PHP-DB] MySQL query problems...

2005-03-24 Thread J. Connolly
yeah...errora are important. I do not escape my quotation marks in a 
query. I use single quotes within my insert and select statements.
If it says No valis MySQL resource then you are returning 0 records 
which may be caused by escaping the quotations.

I follow this pattern
$sql =INSERT INTO table VALUES ('some value','another value','etc');
NIPP, SCOTT V (SBCSI) wrote:
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:  [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


Re: [PHP-DB] MySQL query problems...

2005-03-24 Thread Bastien Koert
Not quite correct, No valis MySQL resource means the query and/or link 
failed in connection in some way. A correct and proper query MAY easily 
return 0 rows and that is correct and will give you a  valid resource 
(handle) and simply no data.

Bastien
From: J. Connolly [EMAIL PROTECTED]
CC: php-db@lists.php.net
Subject: Re: [PHP-DB] MySQL query problems...
Date: Thu, 24 Mar 2005 08:35:56 -0500
yeah...errora are important. I do not escape my quotation marks in a query. 
I use single quotes within my insert and select statements.
If it says No valis MySQL resource then you are returning 0 records which 
may be caused by escaping the quotations.

I follow this pattern
$sql =INSERT INTO table VALUES ('some value','another value','etc');
NIPP, SCOTT V (SBCSI) wrote:
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:  [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] MySQL query problems...

2005-03-24 Thread NIPP, SCOTT V \(SBCSI\)
OK.  I think I have resolved this issue.  The problem I am
having now is that I have a simple table that is a list of systems to
exclude from the display.  I am having trouble figuring out how to
structure my query to actually exclude the systems in this table.  Here
is what I tried, and it gives me 13 instances of every entry, 13 is the
number of hostnames in the exclusion table.

$query = SELECT AllMid_Data.CPU_Hostname FROM AllMid_Data, exclusion
  WHERE AllMid_Data.CPU_IN_SVC = \Y\ 
  AND AllMid_Data.CPU_DNS = \sbcld.sbc.com\ 
  AND AllMid_Data.CPU_Hostname != exclusion.hostname
  ORDER BY CPU_Hostname ASC;
$results = mysql_query($query, $Prod) or die(mysql_error());
$system = mysql_fetch_assoc($results);

Additionally, what I am actually working towards is that if a
system shows up in either of the other queries it gets excluded from
this one.  I have not tried anything to make that happen yet.  I will
tackle that challenge once I can resolve this part.  Thanks again.

Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com



-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 24, 2005 7:36 AM
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] MySQL query problems...


yeah...errora are important. I do not escape my quotation marks in a 
query. I use single quotes within my insert and select statements.
If it says No valis MySQL resource then you are returning 0 records 
which may be caused by escaping the quotations.

I follow this pattern
$sql =INSERT INTO table VALUES ('some value','another value','etc');

NIPP, SCOTT V (SBCSI) wrote:

   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:  [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



[PHP-DB] MySQL query problems...

2005-03-23 Thread NIPP, SCOTT V \(SBCSI\)
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:  [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



RE: [PHP-DB] MySQL query problems...

2005-03-23 Thread Bastien Koert
um, the errors might be helpful
bastien
From: NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] MySQL query problems...
Date: Wed, 23 Mar 2005 17:18:44 -0600
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:  [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