Hi gus, I was just starting a script that retreves data from a mySql database ( I know... basic right
) but I keep getting this error:
Code:
Fatal error: Call to undefined function mysql_connect() in C:\a\directory\here\members.php on line 11
Here's the code on members.php (unfinished btw)
PHP Code:
Results:
<?php
$cat = $_GET['cat'];
$host="http://a-host-here.url"; // Host name
$username="my-username"; // Mysql username
$password="my-password"; // Mysql password
$db_name="a-database-name"; // Database name
$tbl_name="a-table-name"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("Sorry, cannot connect to the database.");
mysql_select_db("$db_name")or die("Sorry, cannot select the database");
// Retrieve data from database
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td width="10%"><? echo $rows['last']; ?></td>
<td width="30%"><? echo $rows['first']; ?></td>
<td width="30%"><? echo $rows['website']; ?></td>
<td width="30%"><? echo $rows['email']; ?></td>
</tr>
</table>
<?
// close while loop
}
// close connection
mysql_close();
?>
What is wrong, and why doesn't it trigger the "or die" after it if it cannot connect?
Thanks,
Bookmarks