bunny1
03-24-2007, 03:32 AM
Any idea what it is
mysql_query(): Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2)
i am calling a function in another page using include at the top of the page to get a connection to the database
Could this have anything to do with the problem
<?php
include("db.php");
function AddItem($itemId, $qty)
{
$result = mysql_query("select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
mysql_query("insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)");
}
else
{
UpdateItem($itemId, $qty);
}
}
The page i am calling uses this code
<?php
$server="servername";
$user="user";
$pass="pass"; //these are set to the correct values
$database="db";
function ConnectToDb($server, $user, $pass, $database)
{
$s = mysql_connect($server, $user, $pass);
$d = mysql_select_db($database, $s);
if(!$s || !$d)
return false;
else
return true;
}
Thanks
mysql_query(): Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2)
i am calling a function in another page using include at the top of the page to get a connection to the database
Could this have anything to do with the problem
<?php
include("db.php");
function AddItem($itemId, $qty)
{
$result = mysql_query("select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
mysql_query("insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)");
}
else
{
UpdateItem($itemId, $qty);
}
}
The page i am calling uses this code
<?php
$server="servername";
$user="user";
$pass="pass"; //these are set to the correct values
$database="db";
function ConnectToDb($server, $user, $pass, $database)
{
$s = mysql_connect($server, $user, $pass);
$d = mysql_select_db($database, $s);
if(!$s || !$d)
return false;
else
return true;
}
Thanks