Re: [PHP-DB] Nothing returned

2001-11-04 Thread Jesse Goerz

On Saturday 03 November 2001 17:29, Martin wrote:
 Why am I not getting anything returned from this function?
 I have code doing a if user exists and b if user doesn't
 exist. I'm not getting any numRows result apparently. The
 query is OK and returns 1 user for $name=admin. I'm not
 getting any errors from isError.

 Martin

 function exists($name)
 {

 $sql = SELECT * FROM users WHERE
 (name='$name'); $res = $db-query($sql);
 if (DB::isError($res)) {
 die ($res-getMessage());
 }
   ---if($res)
 {
 $Rows = $res-numRows();
 if($Rows  0)
 {
 return(TRUE);
 } else
 {
 return(FALSE);
 }
 }
 }

If you're not getting any errors it's either a logic error or 
your sql statement is messed up.

1.  Is the line I marked above always testing false?  Put some 
prints or echos inside the if conditions and test your logic.
2.  Log in to the mysql server and run your query directly with 
the value you expect.  Do you get the results you're looking for?
3.  Test the variable in the SQL statement with a print or echo. 
 Are you actually passing what you think to $sql?

HTH,
Jesse


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Nothing returned

2001-11-03 Thread boclair


- Original Message - 
From: Martin [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, November 04, 2001 8:29 AM
Subject: [PHP-DB] Nothing returned


: Why am I not getting anything returned from this function?
: I have code doing a if user exists and b if user doesn't exist. I'm not 
: getting any numRows result apparently. The query is OK and returns 1 user 
: for $name=admin. I'm not getting any errors from isError.
: 
: Martin
: 
: function exists($name)
: {
: 
: $sql = SELECT * FROM users WHERE (name='$name');

How about 
$name=admin

and 
WHERE name=$name

Tim Morris


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Nothing returned

2001-11-03 Thread Peter Lovatt

$sql = SELECT * FROM users WHERE (name='$name')

if you are not getting an error, it is usually worth echoing the query SQL

echo $sql ;

and perhaps trying it manually.

Is it possible the quotes around the $name are giving

SELECT * FROM users WHERE (name='$name')
and not evaluating $name

rather than

SELECT * FROM users WHERE (name='fred')

which you wanted

Peter


 : Why am I not getting anything returned from this function?
 : I have code doing a if user exists and b if user doesn't exist. I'm not
 : getting any numRows result apparently. The query is OK and
 returns 1 user
 : for $name=admin. I'm not getting any errors from isError.
 :
 : Martin
 :
 : function exists($name)
 : {
 :
 : $sql = SELECT * FROM users WHERE (name='$name');

 How about
 $name=admin

 and
 WHERE name=$name

 Tim Morris


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Nothing returned

2001-11-03 Thread Martin

Peter Lovatt wrote:

 $sql = SELECT * FROM users WHERE (name='$name')
 
 if you are not getting an error, it is usually worth echoing the query SQL
 
 echo $sql ;
 
 and perhaps trying it manually.
 
 Is it possible the quotes around the $name are giving
 
 SELECT * FROM users WHERE (name='$name')
 and not evaluating $name
 
 rather than
 
 SELECT * FROM users WHERE (name='fred')
 
 which you wanted

echo $sql gives me:
SELECT * FROM users WHERE (name='admin') 
when entering admin as user. So the name is passed to the function but from 
then on ...

M.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]