Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: error

  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    error

    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 Code:
    <?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 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

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You've included the code for the function but you aren't calling the function anywhere. You just need to add
    PHP Code:
    ConnectToDb($server$user$pass$database); 
    after the include, or put that inside the include-- however you want to do it.

  • #3
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    im really silly
    thanks!

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Bunny, I've told you before. Use a subject title that describes what your problem is.

  • #5
    Regular Coder Armondo's Avatar
    Join Date
    Feb 2007
    Posts
    144
    Thanks
    3
    Thanked 0 Times in 0 Posts
    if you didn't give him an infraction...then i am going to get mad. i recieved a infraction once for "some minor css trouble"...and he has "error". that is like 2x worse >_>.
    ..
    ▲ ▲


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •