doutang2382 2012-09-11 15:44
浏览 44
已采纳

网站迁移到雪豹服务器后,“没有数据库选择”

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.

  • 写回答

4条回答 默认 最新

  • douren7179 2012-09-11 16:07
    关注

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来