Re: [PHP-DB] need help with fetching a result using a function
Ahh, thats true. I thought its wokring in mysql. put a * after the select Tibor - Original Message - From: "John W. Holmes" <[EMAIL PROTECTED]> To: "'David Rice'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Sunday, March 02, 2003 5:28 PM Subject: RE: [PHP-DB] need help with fetching a result using a function > > I am trying to write a few functions for a project i need to do for > > school, > > this function should return all the inactive, or active users (1 or 0 > > staffstatusid) as an array for creating a drop down menu. > > > > Now when i perform the following code (yes it is included in a script > that > > connects to the databas i am using) it returns the following error. > > > > "Warning: Supplied argument is not a valid MySQL result resource in > > /home/filterseveuk/public_html/project/getusers.php on line 7" > > > > and underneath the error it prints the value of var_dump($data) > > which is " NULL" > > > > any ideas how to fix this? > > > > > > = > > > function getusers($status){ > > > > $query = "SELECT FROM Staff WHERE Staffstatusid = '$status'"; > > Select _WHAT_ from the table? You do not have a valid query... > > > $result = mysql_query($query); > > $row = mysql_fetch_array($result); > > $users[$status] = $row ; > > return $users[$status] ; > > } > > $status = 0 ; > > $data = getusers($status); > > var_dump($data); > > > > echo $data; > > ?> > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.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] need help with fetching a result using a function
> I am trying to write a few functions for a project i need to do for > school, > this function should return all the inactive, or active users (1 or 0 > staffstatusid) as an array for creating a drop down menu. > > Now when i perform the following code (yes it is included in a script that > connects to the databas i am using) it returns the following error. > > "Warning: Supplied argument is not a valid MySQL result resource in > /home/filterseveuk/public_html/project/getusers.php on line 7" > > and underneath the error it prints the value of var_dump($data) > which is " NULL" > > any ideas how to fix this? > > > = > function getusers($status){ > > $query = "SELECT FROM Staff WHERE Staffstatusid = '$status'"; Select _WHAT_ from the table? You do not have a valid query... > $result = mysql_query($query); > $row = mysql_fetch_array($result); > $users[$status] = $row ; > return $users[$status] ; > } > $status = 0 ; > $data = getusers($status); > var_dump($data); > > echo $data; > ?> ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] need help with fetching a result using a function
Sorry, Tried error_reporting()? The query is invalid that's sure. Maybe '0' is not integer value (i dont know well mysql)... (or is there any mysql_error() to get mysql's error, why were the query invalid?) Tibor - Original Message - From: "David Rice" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Sunday, March 02, 2003 4:59 PM Subject: Re: [PHP-DB] need help with fetching a result using a function > > You haven't thorougly read my message, about 4/5 lines down i have said > "(yes it is included in a script that connects to the database i am using)" > :) > i have another script that calls this function script, and at the top of it, > it calls a script that contains my connection information. > > I have tested it with other queries that work... and there is no problem, i > am definately connected to the database > > > > > > >From: Koleszár Tibor <[EMAIL PROTECTED]> > >To: "David Rice" <[EMAIL PROTECTED]> > >Subject: Re: [PHP-DB] need help with fetching a result using a function > >Date: Sun, 2 Mar 2003 16:54:25 +0100 > > > >Hello, > > > >You have forgotten to connect :) > >This error occurs when the $result variable is false and it is not > >a resource (database query) id. > > > >Tibor > > > >PS: > >for any db: > > $conn_id = connect(...); > > $result_id = query($conn_id, ....); > > $row = fetch($result_id); > > > >... > > > > > > > >- Original Message - > >From: "David Rice" <[EMAIL PROTECTED]> > >To: <[EMAIL PROTECTED]> > >Sent: Sunday, March 02, 2003 4:49 PM > >Subject: [PHP-DB] need help with fetching a result using a function > > > > > > > > > > I am trying to write a few functions for a project i need to do for > >school, > > > this function should return all the inactive, or active users (1 or 0 > > > staffstatusid) as an array for creating a drop down menu. > > > > > > Now when i perform the following code (yes it is included in a script > >that > > > connects to the database i am using) it returns the following error. > > > > > > "Warning: Supplied argument is not a valid MySQL result resource in > > > /home/filterseveuk/public_html/project/getusers.php on line 7" > > > > > > and underneath the error it prints the value of var_dump($data) > > > which is " NULL" > > > > > > any ideas how to fix this? > > > > > > > > > = > > > > > function getusers($status){ > > > > > > $query = "SELECT FROM Staff WHERE Staffstatusid = '$status'"; > > > $result = mysql_query($query); > > > $row = mysql_fetch_array($result); > > > $users[$status] = $row ; > > > return $users[$status] ; > > > } > > > $status = 0 ; > > > $data = getusers($status); > > > var_dump($data); > > > > > > echo $data; > > > ?> > > > > > > _ > > > Use MSN Messenger to send music and pics to your friends > > > http://messenger.msn.co.uk > > > > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > _ > Overloaded with spam? With MSN 8, you can filter it out > http://join.msn.com/?page=features/junkmail&pgmarket=en-gb&XAPID=32&DI=1059 > > > -- > 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] need help with fetching a result using a function
You haven't thorougly read my message, about 4/5 lines down i have said "(yes it is included in a script that connects to the database i am using)" :) i have another script that calls this function script, and at the top of it, it calls a script that contains my connection information. I have tested it with other queries that work... and there is no problem, i am definately connected to the database From: Koleszár Tibor <[EMAIL PROTECTED]> To: "David Rice" <[EMAIL PROTECTED]> Subject: Re: [PHP-DB] need help with fetching a result using a function Date: Sun, 2 Mar 2003 16:54:25 +0100 Hello, You have forgotten to connect :) This error occurs when the $result variable is false and it is not a resource (database query) id. Tibor PS: for any db: $conn_id = connect(...); $result_id = query($conn_id, ); $row = fetch($result_id); ... - Original Message - From: "David Rice" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, March 02, 2003 4:49 PM Subject: [PHP-DB] need help with fetching a result using a function > > I am trying to write a few functions for a project i need to do for school, > this function should return all the inactive, or active users (1 or 0 > staffstatusid) as an array for creating a drop down menu. > > Now when i perform the following code (yes it is included in a script that > connects to the database i am using) it returns the following error. > > "Warning: Supplied argument is not a valid MySQL result resource in > /home/filterseveuk/public_html/project/getusers.php on line 7" > > and underneath the error it prints the value of var_dump($data) > which is " NULL" > > any ideas how to fix this? > > > = > > function getusers($status){ > > $query = "SELECT FROM Staff WHERE Staffstatusid = '$status'"; > $result = mysql_query($query); > $row = mysql_fetch_array($result); > $users[$status] = $row ; > return $users[$status] ; > } > $status = 0 ; > $data = getusers($status); > var_dump($data); > > echo $data; > ?> > > _ > Use MSN Messenger to send music and pics to your friends > http://messenger.msn.co.uk > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > _ Overloaded with spam? With MSN 8, you can filter it out http://join.msn.com/?page=features/junkmail&pgmarket=en-gb&XAPID=32&DI=1059 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] need help with fetching a result using a function
I am trying to write a few functions for a project i need to do for school, this function should return all the inactive, or active users (1 or 0 staffstatusid) as an array for creating a drop down menu. Now when i perform the following code (yes it is included in a script that connects to the databas i am using) it returns the following error. "Warning: Supplied argument is not a valid MySQL result resource in /home/filterseveuk/public_html/project/getusers.php on line 7" and underneath the error it prints the value of var_dump($data) which is " NULL" any ideas how to fix this? = $query = "SELECT FROM Staff WHERE Staffstatusid = '$status'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $users[$status] = $row ; return $users[$status] ; } $status = 0 ; $data = getusers($status); var_dump($data); echo $data; ?> _ Use MSN Messenger to send music and pics to your friends http://messenger.msn.co.uk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php