RE: [PHP-DB] mysql_select_db() and mysql_query()

2002-11-30 Thread John W. Holmes
 A friendly error message advised me that mysql_db_query is
deprecated
 and
 to use mysql_select_db() and
 
 mysql_query(). but I can't seem to get past this return in the
Browser:
 Parse error: parse error in c:\program files\apache
 
 group\apache\htdocs\crup_hs_local\result.php on line 58. I think I
don't
 understand the basic syntax.
 
 /*$result = mysql_db_query($dbname,$sql);*/
 /*mysql_db_query is deprecated; use mysql_select_db() and
mysql_query()*/
 $result = mysql_select_db($dbname) or die(mysql_error();

You're missing a closing parenthesis on the above line.

---John Holmes... 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] mysql_select_db() and mysql_query()

2002-11-29 Thread Dan Martin
A friendly error message advised me that mysql_db_query is deprecated and
to use mysql_select_db() and

mysql_query(). but I can't seem to get past this return in the Browser:
Parse error: parse error in c:\program files\apache

group\apache\htdocs\crup_hs_local\result.php on line 58. I think I don't
understand the basic syntax.

/*$result = mysql_db_query($dbname,$sql);*/
/*mysql_db_query is deprecated; use mysql_select_db() and mysql_query()*/
$result = mysql_select_db($dbname) or die(mysql_error();
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);

I've search my references and the PHP Manual, but can't seem to figure this
out. I'd be grateful for a reference or guidance.

Thanks,

Dan




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] mysql_select_db() and mysql_query()

2002-11-29 Thread Beth Gore
Hi Dan,

Dan Martin wrote:


group\apache\htdocs\crup_hs_local\result.php on line 58. I think I don't
understand the basic syntax.

/*$result = mysql_db_query($dbname,$sql);*/
/*mysql_db_query is deprecated; use mysql_select_db() and mysql_query()*/
$result = mysql_select_db($dbname) or die(mysql_error();
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
 

A valid database connection, open and query is as follows:

/* connect to the server, and assign the connection to $Conn */
$conn = mysql_connect(mysqlserver,myusername,mypassword) or 
die(Could not connect);

/* select a database using $conn as the connection */
mysql_select_db($conn) or  die(Unable to Connect);

/* a SQL query we'd like to make */
$SQL = SELECT * FROM foobar;

/* get a record set from the mySQL database using the SQL query, and put 
the data in $rs */
$rs = mysql_query($SQL);

/* get a row of data from $rs, and assign it to $foo_row */
$foo_row = mysql_fetch_array($rs);

/* print out some of the stuff from $foo_row */
echo foo_row['foo'];
echo foo_row['bar'];


The parse error you got comes from the 'or die(mysql_error();' bit.. you 
forgot the final closing bracket, i.e. it should have been:

die( mysql_error() );

Have another go! It's one of those things you only ever write once, and 
just cut and paste it for everything you ever do ever again!

Beth Gore


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php