Re: [PHP-DB] Help w/ displaying return vals
Ryan: The followoing error message: >Warning: Supplied argument is not a valid MySQL result resource means that a php function hasn't been supplied witht the correct number of arguments. Try the following: $link = mysql_connect("host","yourusername","yourpassword") or die("Died at connection."); table_name = "yourtable"; mysql_select_db("dbname"); $sql = "SELECT * FROM yourtable"; $result = mysql_query ($result, connection); $fields = mysql_num_fields($result); $rows = mysql_num_rows($result); $table = mysql_field_table($result, $i); echo "Your '".$table."' table has ".$fields." fields and ".$rows." records " - - EOP - - //All I've done is to give mysql_query() two arguments //Remover gaps between mysql functions anf their arguments (Which they //shouldn't have) And given mysql_connect all 3 arguments it should have to make a successful connection to your database server. (Not sure wether you missed these out simply for clarity though) Hope that all helps and makes sense!! Cheers Russ #---# "Believe nothing - consider everything" Russ Michell Anglia Polytechnic University Webteam http://gertrude.sipu.anglia.ac.uk/webteam [EMAIL PROTECTED] +44 (0)1223 363271 ext 2331 www.theruss.com #---# -- 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] Help w/ displaying return vals
Use or die( mysql_error()) on every mysql function or command you're performing, this will tell you what is going wrong . HTH Jayme. -Mensagem Original- De: <[EMAIL PROTECTED]> Para: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Enviada em: quarta-feira, 14 de março de 2001 19:47 Assunto: [PHP-DB] Help w/ displaying return vals > Here's my php program, I think $result never gets assigned a value, staying > null or whatever. > > $link = mysql_connect("host"); > > mysql_select_db("dbname"); > > $result = mysql_query ("SELECT * FROM table"); > > $fields = mysql_num_fields ($result); > $rows = mysql_num_rows ($result); > > $table = mysql_field_table ($result, $i); > > echo "Your '".$table."' table has ".$fields." fields and ".$rows." records > " > > - - EOP - - > > The problem comes on the lines that reference the variable $result. > > I keep getting this in the browser... leading me to believe that $result is > null: > > Warning: Supplied argument is not a valid MySQL result resource > > > help! > > Thankx0r > > Ryan > > > > > -- > 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]
[PHP-DB] Help w/ displaying return vals
Here's my php program, I think $result never gets assigned a value, staying null or whatever. $link = mysql_connect("host"); mysql_select_db("dbname"); $result = mysql_query ("SELECT * FROM table"); $fields = mysql_num_fields ($result); $rows = mysql_num_rows ($result); $table = mysql_field_table ($result, $i); echo "Your '".$table."' table has ".$fields." fields and ".$rows." records " - - EOP - - The problem comes on the lines that reference the variable $result. I keep getting this in the browser... leading me to believe that $result is null: Warning: Supplied argument is not a valid MySQL result resource help! Thankx0r Ryan -- 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]