problem with database connection. . Really stumped me

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

problem with database connection. . Really stumped me

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

thanks :) Will try it tonight :)

Rob
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

Try:

Code: Select all

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