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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Location
    Colorado
    Posts
    132
    Thanks
    7
    Thanked 1 Time in 1 Post

    Mysql Query not executing inside dynamic image

    So i have an image that checks to see if your on AIM or not. In the process I log your aim username, the time that the image was viewed, and your myspace friendid. For whatever reason my mysql is not working, the code looks fine to me and all the tables/columns exist. Can anyone tell me what Im doing wrong?

    PHP Code:
    $link mysql_connect("192.168.2.7","myspace_aim","*****");
    mysql_select_db("myspace_aim");
    $sql "SELECT * FROM users WHERE mid = '$ref' OR ausr = '$username'";
    $result mysql_query($sql);
    $now time();
    $sql "INSERT INTO `users` ( `mid` , `ausr` , `when` ) VALUES ('$ref', '$username', '$now')";
    mysql_query($sql);
    mysql_close($link); 
    $ref and $username are defined earlier in the script.
    -bubbles

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i don't realy understand a lott of your code. most of it is pointless (closing the connection at the end, storing the linkID without using it, running a select without using the result, storing the time in a variable) + you don't have any debugging included. Below code would result in exactly the same as yours, but is easier to debug
    PHP Code:
    $link mysql_connect("192.168.2.7","myspace_aim","*****") or die('Unable to connect to db-server');
    mysql_select_db("myspace_aim") or die('Unable to select db');  
    $sql "INSERT INTO `users` ( `mid` , `ausr` , `when` ) VALUES ('$ref', '$username', '"time() ."')"
    mysql_query($sql$link) or die('Unable to execute query: '$sql '<br />Error:' mysql_error()); 
    maybe try it like that. + it might help to be a bit more informative then 'my mysql is not working'
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

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