English 中文(简体)
MySQL的表格在确实存在时就存在。
原标题:MySQL table doesn t exist when it does exist
  • 时间:2012-05-07 14:05:02
  •  标签:
  • php
  • mysql

我要问:

mysql_select_db( scanner );
$query = "SELECT * FROM scanner.proxy ORDER BY RAND() LIMIT 20";
$result = mysql_query($query) or die(mysql_error());

它告诉我:扫描仪。 代理公司存在,尽管我确实有数据库的表格。 它令人ir慕,引起我的其他询问。

UPADTE:

当我这样说时:

$user= root ;
            $user= root 
        $password= <removed_password> ;
        $dbname =  scanner ;
        $host =  localhost ;
        $link = mysql_connect($host, $user, $password) or die (mysql_error());

mysql_select_db($dbname, $link) or die (mysql_error());

它给了我......

不详的数据库扫描仪

但是,我可以看到Scanner数据库位于Sphpmyadmin。

Even when I type in phpmyadmin the sql statement SHOW TABLES FROM scanner

它说可以找到扫描器

最佳回答

确保用户能够使用链接,有足够的权利查询表格。 也许该表是由另一个用户创建的。

EDIT: Perhaps you need to grant access to scanner from a remote location. Running this sholud help on that.

GRANT ALL ON scanner.* TO your_user@ IP_ofServer_where_PHP_runs  IDENTIFIED BY  PASSWORD ;
问题回答

我们通过在每张<密码>之前添加重新连接的方法,解决了在同一个文字中连接多个远程MySQL数据库时出现的这一问题。 重新连接的方法既使用<代码>mysql_joint,又使用<代码>mysql_select_db功能。 我们以前曾试图在连接说明中确定新的连接参数,但我们仍然发现数据库的错误和各种不愉快的行为。

您设立了dbname = aws_backlinks,但你试图在你的询问中连接一个不同的数据库。 改变你的联系,把这一条 d倒或仅仅与服务器连接起来,并在问询时建立你的数据库。

$db_host = localhost:Port ; Specify port for localhost. I was facing the same problem and specifying the port solved the problem.

你在我sql_select_db(db)呼吁中遗漏了具体联系(我sql_link(联系))的论点:

$db_host =  localhost ;
$db_username =  root ;
$db_password =  whatever ;
$db_name =  scanner ;
$link = mysql_connect($db_host, $db_username, $db_password);
mysql_select_db($db_name, $link);




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签