脚本在调用mysql_connect()后没有错误, [英] Script dies without error after calling mysql_connect()

查看:91
本文介绍了脚本在调用mysql_connect()后没有错误,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接到mysql与PHP,它不工作。

I'm trying to connect to mysql with PHP and it doesn't work at all.

<?php

$con = mysql_connect('localhost', 'xxxx', 'xxxx');

mysql_select_db("test_site", $con);

$query = mysql_query("SELECT * FROM test");

echo $query;

mysql_close($con);
?>

我的整个脚本停在第一行之后($ con = ...)。我试过添加回声TEST;紧接着那条线,它没有显示。当我尝试在该行之前打印文本时,它工作正常。即使我添加了:

My entire script stops right after the first line($con = ...). I tried adding echo "TEST"; right after that line and it didn't show. When I try to print text before that line, it works fine. Even if I add something like:

if (!$con)
{
  die('Could not connect: ' . mysql_error());
}

没有错误显示。我假设这意味着连接是好的...所以为什么我的脚本停止?当我通过我的终端做同样的事情,我得到*从测试,就像我的需要。不适用于PHP。

No error shows. I'm assuming that means the connection was fine... so why does my script stop? When I do the same thing through my terminal I get * from test, just like I need. Not with PHP.

帮助? =]

感谢

编辑:

nvm,找到一种方法使它工作。

nvm, found a way to make it work.

推荐答案

您需要安装php5 mysql模块。这将安装模块,并在Ubuntu上的PHP中进行设置。

You need to install the php5 mysql modules. This will install the modules and set them up in PHP on Ubuntu.

sudo apt-get install php5-mysql

这篇关于脚本在调用mysql_connect()后没有错误,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆