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);
?>
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());
}
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.
Help? =]
thanks
edit:
nvm, found a way to make it work.
You need to install the php5 mysql modules. This will install the modules and set them up in PHP on Ubuntu.