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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Posts
    217
    Thanks
    25
    Thanked 1 Time in 1 Post

    weird php mysql error

    I'm trying to execute the script below, but I'm getting this as result:

    [phpBB Debug] PHP Notice: in file /mdwphp/add_gmember.php on line 47: mysql_query(): supplied argument is not a valid MySQL-Link resource
    Er is een fout opgetreden: INSERT INTO 'hello' VALUES ('gpfsjaak','1', 'July 17 2010','pictures','test.jpg'); :Access denied for user 'a3718717_members'@'192.168.0.3' to database 'hello'

    I'm using a phpbb script earlier in the script, but that has nothing to do with the error. The phpdebug says it's not a valid Mysql link resource at $result = mysql_query($string,$db_selected); Though I checked everything and all database/host settings are filled in correctly. Perhaps there is an error in the way I try to connect?



    Code:
    $string = "INSERT INTO 'hello' VALUES ('$gebruiker','1', '$today_plus_1_month','pictures','test.jpg');"; 
    
    
    
    $con = mysql_connect("mysql3.***************","a3718717_members",$wachtwoord);
    $db_selected = mysql_select_db('hello', $con);
    
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    $result = mysql_query($string,$db_selected);
    
    if (!$result) {echo "Er is een fout opgetreden: $string :". mysql_error();}else{echo "1 record added";}
    mysql_close($con);
    
    }
    ?>

  • #2
    New Coder
    Join Date
    Jan 2010
    Location
    UT
    Posts
    35
    Thanks
    1
    Thanked 3 Times in 3 Posts
    The access denied error means that your connection information is either wrong or your not allowed to connect to the server from the IP address your running the script from.

    Are you trying to connect to a remote database on a different server than the script is running? If so, have you white listed the IP address of the site/server/computer your script is on?

    Also, some times you don't need to specify the connection in your mysql functions (such as mysql_select_db and mysql_query). Try it without that 2nd (optional) parameter that specifies the connection and see if you still get an error.

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    It'd give a much more descriptive error if you put it like
    Code:
    $con = mysql_connect("mysql3.***************","a3718717_members",$wachtwoord) or die( mysql_error());
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    New Coder
    Join Date
    Jan 2010
    Location
    UT
    Posts
    35
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by abduraooft View Post
    It'd give a much more descriptive error if you put it like
    Code:
    $con = mysql_connect("mysql3.***************","a3718717_members",$wachtwoord) or die( mysql_error());
    ^ first step to figuring out any problems with mysql queries. It may be tedious to add those in after every, single, mysql, function, but in the end its worth the time.
    Just here to help.


  •  

    Posting Permissions

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