Hi Dan, Dan Martin wrote:
group\apache\htdocs\crup_hs_local\result.php on line 58". I think I don'tA valid database connection, open and query is as follows:
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);
/* 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