Log in

View Full Version : Trying to connect to MySQL at my ISP (Demon.net)



johnmwwarks
12-03-2008, 09:12 AM
Hi folks

This code does not produce an error, trouble is it does not produce anything at all. All it is supposed to do is to connect to a database on my ISP's server via PHPAdmin and return the 7 or 8 records I put in trhe vacancies table yesterday. - Any ideas............................anyone please

I have tried it on localhost too with exactly the same result, so at least whatever it is doing is at least consistent, trouble is what is it doing, when all the text books say it should be connecting and returning records.

I am beginning to think there is either something wrong with the MySQL installation at my/my ISP's server.


TIA John



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Recruitment"/>
<meta name="keywords" content="Recruitment">
<meta name="author" content="John W."/>
<title>Warwickshire Mobile Computer Repair Service</title>
</head>

<body>
<?php # - mysql_connect.php

define ('DB_USER','USERNAME');
define ('DB_PASSWORD','PASSWORD');
define ('DB_HOST','HOST');
define ('DB_NAME','DB');

$dbc = @mysql_connect (DB_HOST,DB_USER,DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error());
mysql_select_db (DB_NAME) OR die ('Could not select the database' . mysql_error());

$query="SELECT * FROM vacancies";
$result = mysql_query ($query);

while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
echo "Name :{$row['Ref']} <br>";
}

mysql_close();
?>

</body>
</html>

rubing
12-03-2008, 03:40 PM
The @ symbol is for suppressing output. You know so if there's an error and mysql barfs up a bunch of sensitive info you don't want others to see while in production. However, right now when you are developing you don't want to use those @ symbols. So, remove it and then you should see the error being thrown.

Also, posting your password is usually a bad idea :eek: