Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001062

Re: [PHP-DB] newbie: Trying to select a database in php From: Dino Krstulovic (dino.krstulovic <email protected>)
Date: 06/20/01

At 09:06 20. 06. 01 +0100, you wrote:
>Im using win2k and php to retrieve and dipslay database records, however
>whenever the page is loaded in a browser I get the following error (the
>line in question is in bold)
>
>Fatal error: Call to undefined function: msql_select_db() in
>D:\ASP\test\php\default.php on line 18
>
>The code I am using is below
>
><?php
>
>$connect = mysql_connect();
>
>if(!$connect){
>echo "Could not etsablish connection to mySQL!";
>exit;
>}
>
>$database = "dvd_listings";
>
>$dbb = msql_select_db($database,$connect) or die("Unable to select
>Database!");
>
>$sql = "SELECT * FROM dvd_main";
>
>$sql_result = mysql_query($sql,$connect);
>
>echo "<table border=1>";
>echo "<tr><td>DVD Title</td></tr>";
>
>while($row = mysql_fetch_array($sql_result)){
>
>$title = $row["main_title"];
>echo "<tr><td>$title</td></tr>";
>
>}
>
>echo "</table>";
>
>mysql_free_result($sql_result);
>mysql_close($connection);
>?>
>
>Any help would be appreciated

Hi !

try this

<?
echo "<table border=1>";
echo "<tr><td>DVD Title</td></tr>";
$connection = mysql_connect("$server","$username","$pass") or die ("Unable
to connecto to MySQL Server");
$db = mysql_select_db("$database", $connection) or die ("Unable to get
requested database");

$sql = "SELECT * FROM dvd_main";

>$sql_result = mysql_query($sql,$connection)or die ("Couldn't execute SQL
>query");
>while($row = mysql_fetch_array($sql_result)){
>
>$title = $row["main_title"];
>echo "<tr><td>$title</td></tr>";
>};
>
>echo "</table>";

?>

hope this helps....

Dino Krstulovic
SDnet software
www.sdnet.hr

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>