Search code examples
phpmysqlosx-snow-leopard

"No database Selected" after website migration to snow leopard server


I'm migrating a website from a windows server to a snow leopard server (OSX 10.6.8 to be exact) and I'm running into several compatibility issues with my mysql queries. Every query returns a "No database selected" error and I can't make heads or tales of it. I've done some research on it and wasn't able to find the answer I was looking for. Here are some indicators that may be useful in solving my issues.

Here is my connect file include:

$link = mysql_connect("localhost", "username", "password") or die("Invalid query: " . mysql_error());
mysql_select_db("tradeport", $link) or die("Database Connection Error: ".mysql_error());

Here is one of my queries:

$sSQL="SELECT mainPhone FROM admins";
$result21=mysql_query($sSQL) or die ("MySQL err: ".mysql_error()."<br>".$sSQL);

if($row21 = mysql_fetch_array($result21))
{$phoneMain = $row21['mainPhone'];}

Another note I would like to add is that when I began migration on this site all of the php was showing in the page source. I had to replace all php brackets with the more formal ones as shown here:

<? //before

<?php //after

I'm currently running PHP version 5.3.8 and MySQL version 5.0.92.

Any information would be greatly apreciated.


Solution

  • I've tried that and it gives me this error in return: SELECT command denied to user ''@'localhost' for table – Trig3rz 20 mins ago

    Check that the database user is setup with the correct permissions GRANT SELECT ON db.* TO user@'localhost' IDENTIFIED BY 'pass';

    You might want to check the php.ini file on the original server to see what differences there are. <? is php short tags and it is enabled in the php ini file with this line:

    short_open_tag=On