Shadow2097
Programmer
Hi all,
I'm not sure if this is a MySQL problem or a PHP problem, but I'm going to start here. I'm trying to run a simple database query that will display the results in an HTML table. Unfortunately, I can't get the script to get past the mysql_connect() function. Here's relevant parts of the script:
<code>
<?php
//connect to server, then test for failure
if(!($dbLink = mysql_connect("localhost","<changed for security>","<changed for security>"
))
{
print("Failed to connect to database!<br>\n"
;
print("Aborting!<br>\n"
;
exit();
}
//select database, then test for failure
if(!($dbResult = mysql_query("USE shadow",$dbLink)))
{
print("Can't use 'shadow' database!<br>"
;
print("Aboring!<br>"
;
exit();
}
//select everything from the PERSON table
$Query = "SELECT * from PERSON " .
"ORDER BY NAME ";
if(!($dbResult = mysql_query($Query,$dbLink)))
{
print("Couldn't execute query!<br>\n"
;
print("MySQL reports: " . mysql_error() . "<br>\n"
;
print("Query was: $Query<br>\n"
;
exit();
}
...
</code>
Everything else is just the HTML table building.
This is the output I get on the webpage:
<output>
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/local/apache/htdocs/shadowrealm/db_test.php on line 3
Failed to connect to database!
Aborting!
</output>
Is there something I'm missing in my PHP or does this sound like a MySQL configuration issue?
Thanks,
-Shadow
I'm not sure if this is a MySQL problem or a PHP problem, but I'm going to start here. I'm trying to run a simple database query that will display the results in an HTML table. Unfortunately, I can't get the script to get past the mysql_connect() function. Here's relevant parts of the script:
<code>
<?php
//connect to server, then test for failure
if(!($dbLink = mysql_connect("localhost","<changed for security>","<changed for security>"

{
print("Failed to connect to database!<br>\n"

print("Aborting!<br>\n"

exit();
}
//select database, then test for failure
if(!($dbResult = mysql_query("USE shadow",$dbLink)))
{
print("Can't use 'shadow' database!<br>"

print("Aboring!<br>"

exit();
}
//select everything from the PERSON table
$Query = "SELECT * from PERSON " .
"ORDER BY NAME ";
if(!($dbResult = mysql_query($Query,$dbLink)))
{
print("Couldn't execute query!<br>\n"

print("MySQL reports: " . mysql_error() . "<br>\n"

print("Query was: $Query<br>\n"

exit();
}
...
</code>
Everything else is just the HTML table building.
This is the output I get on the webpage:
<output>
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/local/apache/htdocs/shadowrealm/db_test.php on line 3
Failed to connect to database!
Aborting!
</output>
Is there something I'm missing in my PHP or does this sound like a MySQL configuration issue?
Thanks,
-Shadow