Current location: Hot Scripts Forums » General Community » Script Requests » Can't connect to local MySQL


Can't connect to local MySQL

Reply
  #1 (permalink)  
Old 03-27-04, 09:24 AM
Abdul Abdul is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Can't connect to local MySQL

Hi there can anyone me please to correct this error i dont know what exactly it means. This is my php script
<?
$sql = "select 1 from temp limit 1";
$check = mysql_query($sql);
$temp = mysql_result($check,0,0);

if ($temp == 0)
{
for ($i=0;$i<sizeof($Sport);$i++)
{
if (isset($Sport[$i]))
{
$query = "CREATE TEMPORARY TABLE IF NOT EXISTS temp
SELECT * FROM unisport WHERE SportID = '$Sport[$i]'";
$result = mysql_query($query);
}



t
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Reply With Quote
  #2 (permalink)  
Old 03-29-04, 04:39 AM
dark one dark one is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
look at http://www.php.net/manual/en/function.mysql-connect.php if you have not already

if this won't help go to the shell and type
> mysql
if you would get "can't connect", than answer is simple - you do not have mysql server installed or you have it down. have a look at www.mysql.com for more details about installation.
try one of the following to get it up:
> service mysqld start
> mysqld start
> /etc/rc.d/init.d/mysqld start
should work
pretty strange yo do not have it started on boot - you've done something wrong during the installation probably.

if
> mysql
would say you "access denied" or connect you to the server, than check mysql hostname your script uses and the host php's mysql api linked to as localhost. unlikely but possible.
Reply With Quote
  #3 (permalink)  
Old 04-01-04, 09:30 AM
Abdul Abdul is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
My database is connect

I think you misinterpreted my question .............................
My Question was not if i m connected to the database
is that i do get connected to the database but i m creating a temproraly table
to store the result return by the query


$sql = "select 1 from temp limit 1"; here i m selecting from temp
$check = mysql_query($sql);
$temp = mysql_result($check,0,0);

if ($temp == 0)
{
for ($i=0;$i<sizeof($Sport);$i++)
{
if (isset($Sport[$i]))
{
$query = "CREATE TEMPORARY TABLE IF NOT EXISTS temp // is this ok to do this?????????????????
SELECT * FROM unisport WHERE SportID = '$Sport[$i]'";
$result = mysql_query($query);
Reply With Quote
  #4 (permalink)  
Old 04-02-04, 02:35 AM
dark one dark one is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
well, if your questions is the script, it seems ok
if you get the following

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

than the problem is not with your script. the problem is with mysql server - it is not running on your machine, so the scripts fails before the line you so concerned about - on mysql_connect instruction. if it was something different, the error would be different. i gave you basic instructions on how to handle this. check mysql.com if you want more about mysql setup.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
mysql crash IMPORTANT comby PHP 0 03-02-04 10:27 AM
I need a bit of help, with MySQL connect H-a-V-o-C_88 PHP 4 12-03-03 02:05 PM
great product for dumping/recovering MySQL databases Dave Brown General Advertisements 1 10-03-03 07:40 AM
upload local mysql to internet borgo PHP 1 06-26-03 12:04 AM


All times are GMT -5. The time now is 11:01 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.