Re: mysql_query() and mysql_db_query() not returning a value
| From: | Mark A Mucha | Date: | Mon, 19 Jun 2000 04:34:03 +0000 |
| Subject: | Re: mysql_query() and mysql_db_query() not returning a value | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-460@lists.php.net to get a copy of this message | ||
Thanks for the help, although I get that nice message saying the query
busted. I can run that same query all day long on mysql and I get results.
Could this be a PHP4/WIN2k/MySQL problem? I realized that the PHP4 dist for
WINDOWS did not contain the MYSQL.dll. Should it have?
But I still can connect to and list the databases in MYSQL.
Again, thanks for the help.
Mark
----- Original Message -----
From: "Erik Stainsby" <stainsby@telus.net>
To: "Mark A Mucha" <mmucha@cfl.rr.com>
Sent: Sunday, June 18, 2000 11:58 PM
Subject: Re: [PHP-DB] mysql_query() and mysql_db_query() not returning a
value
> <HTML>
> <HEAD>
> <TITLE> Looking here, a mysql tester. </TITLE>
> </HEAD>
> <BODY>
>
> <?
> // Do NOT go into a production environment with an unsecured mysql db
> $conn_id = mysql_connect( "crocbyte", "", "");
>
> // declare db target (this is a style issue, but affects syntax style too)
> mysql_select_db( "linkcount" );
>
> // prepack sql statement (style and clarity)
> $query_string = "select * from links";
>
>
> // because db is predeclared with mysql_select_db() above, use
mysql_query()
> here
> if (! $result_pointer = mysql_query( $query_string ))
>
> print "Shit; busted query: $query <p>\n";
> } else {
>
> print "Database connection complete.<br>\n";
> print "The conn number is $conn_id.<br>\n";
>
> // we should not be able to get here with an invalid $result_pointer
> while ( $recordSet = mysql_fetch_row( $result_pointer ) ) {
> print "One row returned:\n<br>";
> print $recordSet[1] . $recordSet[2] . $recordSet[3] ."<br>\n";
> }
> }
> exit;
>
> ?>
> </BODY>
> </HTML>
>
>
>
> ----- Original Message -----
> From: "Mark A Mucha" <mmucha@cfl.rr.com>
> To: <php-db@lists.php.net>; "Erik Stainsby" <stainsby@telus.net>
> Sent: Sunday, June 18, 2000 6:25 PM
> Subject: Re: [PHP-DB] mysql_query() and mysql_db_query() not returning a
> value
>
>
> > Thanks for the reply,
> > It still doesn't work, I get this error, with the source attached at the
> > bottom.
> > Thanks in advance, Mark
> > **********************************************************************
> > Database connection complete.
> > The conn number is Resource id #1.
> >
> > Warning: Supplied argument is not a valid MySQL result resource in
> > c:\inetpub\wwwroot\mysql\tester.php on line 18
> > ***********************************************************************
> >
> > Source
> > <HTML>
> > <HEAD>
> > <TITLE> Looking here, a mysql tester. </TITLE>
> > </HEAD>
> > <BODY>
> > <?
> > if(!($conn = mysql_connect("crocbyte", "", ""))){
> > echo "Error opening database.\n";
> > exit();
> > }
> > else{
> > echo "Database connection complete.<br>\n";
> > echo "The conn number is $conn.<br>\n";
> > }
> > $whatTo = "Select * from links";
> > $result_pointer = mysql_db_query("linkcount", $whatTo, $conn);
> >
> > while ( $recordSet = mysql_fetch_row( $result_pointer ) ) {
> >
> > print "One row returned\n<br>";
> > print $recordSet[1] . $recordSet[2] . $recordSet[3] ."<br>\n";
> > // these can be indexed by the filed name as well
> > // print $recordSet["col_name"] .
> > $recordSet["second_col_name"]."<br>\n";
> > }
> > exit;
> >
> > ?>
> > </BODY>
> > </HTML>
> > ----- Original Message -----
> > From: "Erik Stainsby" <stainsby@telus.net>
> > To: "Mark A Mucha" <mmucha@cfl.rr.com>
> > Sent: Sunday, June 18, 2000 7:36 PM
> > Subject: Re: [PHP-DB] mysql_query() and mysql_db_query() not returning a
> > value
> >
> >
> > > The mysql_query() family of functions does not return the
> > > result set, but a pointer to the result set.
> > >
> > > You then have to retrieve specific rows from that resultset.
> > >
> > > Try
> > >
> > > $result_pointer = mysql_db_query("linkcount", $whatTo, $conn);
> > >
> > > while ( $recordSet = mysql_fetch_row( $result_pointer ) ) {
> > >
> > > print "One row returned\n<br>";
> > > print $recordSet[1] . $recordSet[2] . $recordSet[3] ."<br>\n";
> > > // these can be indexed by the filed name as well
> > > print $recordSet["col_name"] .
> $recordSet["second_col_name"]."<br>\n";
> > > }
> > > exit;
> > >
> > > ----- Original Message -----
> > > From: "Mark A Mucha" <mmucha@cfl.rr.com>
> > > To: <php-db@lists.php.net>
> > > Sent: Sunday, June 18, 2000 4:10 PM
> > > Subject: [PHP-DB] mysql_query() and mysql_db_query() not returning a
> value
> > >
> > >
> > > I can connect to mysql, and get a list of databases, but for some
reason
> I
> > > can't get a query to return a value.
> > >
> > > $recordSet = mysql_db_query("linkcount", $whatTo, $conn); /*
$recordSet
> > > doesn't hold a value after this statement */
> > >
> > > Any ideas. Thanks
> > > Mark
> > >
> > >
> > >
> >
> >
>