Page 1 of 1

problem with database connection. . Really stumped me

Posted: Tue Oct 14, 2003 9:44 am
by robster
Hi all,

Here is the code:

Code: Select all

$dbLink = @mysql_connect($dbasehost,$dbaseuser, $dbasepassword);
	mysql_select_db($dbase);
                   $sql="Select * FROM jobnum ORDER BY recordid ASC";
                   $result = mysql_query ($sql,$dbLink) or die( "problems getting job listing");

                     While ($row = mysql_Fetch_array($result)){
                    $user=$rowї'username'];
                    $pass=$rowї'password'];
                    }
                   mysql_close();
It returns the error "problems getting job listing" but as far as i'm concerned the dbasehost, user and password are all correct. I'm at an absalute loss here...

Can anyone see a problem with the code that might cause the error?

Thanks SO much for your help :)

Rob

Posted: Tue Oct 14, 2003 10:14 am
by twigletmac
Try:

Code: Select all

$result = mysql_query ($sql,$dbLink) or die( "problems getting job listing".'<p>'.mysql_error().'</p><p>'.$sql.'</p>');
to get a MySQL generated error.

Mac

Posted: Tue Oct 14, 2003 10:53 am
by robster
thanks :) Will try it tonight :)

Rob

Posted: Fri Oct 17, 2003 6:09 am
by robster
OK, I gave it a whirl... The error message states:

Code: Select all

problems getting job listing 
No Database Selected 
Select * FROM jobnum ORDER BY recordid ASC
and code looks like this, note that database is DEFINITELY there named correctly etc...

Code: Select all

$dbLink = @mysql_connect($dbasehost,$dbaseuser, $dbasepassword);
mysql_select_db($dbase);
  
$sql="Select * FROM jobnum ORDER BY recordid ASC";
$result = mysql_query ($sql,$dbLink) or die( "problems getting job listing".'<p>'.mysql_error().'</p><p>'.$sql.'</p>');

So what could it mean? It says No Database Selected but... well, I just don't know. Could anyone possibly help?

ta :)

rob

Posted: Fri Oct 17, 2003 6:12 am
by twigletmac
Try changing:

Code: Select all

mysql_select_db($dbase);
to

Code: Select all

mysql_select_db($dbase) or die(mysql_error());
to see if the mysql_select_db() function is giving any errors.

Mac

Posted: Fri Oct 17, 2003 8:09 am
by Bill H
Try:

Code: Select all

<?php
mysql_select_db($dbName, $dbLink);
?>