-1

I am using in a script mysqli_query but i think there is something wrong with the syntaxes. The script did work before, but changing everything form mysql_query to mysqli_query, data is not put anymore correct in the database.

This was the original query:

mysql_query(     "INSERT INTO download_manager (SET filename='".mysqli_real_escape_string($_GET['file'])."'),
                ON DUPLICATE KEY UPDATE downloads=downloads+1");

I changed it with mysqli_query this way:

mysqli_query($link, "INSERT INTO download_manager (SET filename='".mysqli_real_escape_string($_GET['file'])."'),
                ON DUPLICATE KEY UPDATE downloads=downloads+1");

Can someone tell me what i did wrong?

Update: My connection looks like this:

$link = @mysqli_connect($db_host, $db_user, $db_pass, $db_database) or die ("Error " . mysqli_error($link));

mysql_set_charset('utf8');
Frans
  • 11
  • 1

1 Answers1

0

Ensure that the handle stored in $link was generated from a call to mysqli_connect and not mysql_connect:

http://php.net/manual/en/function.mysqli-connect.php

If that fails, check for an error:

die(mysqli_error($link))

Troubleshooting

  • The mysql and mysqli PHP modules are distinct, and you can't mix functions between the modules.
  • Enable error reporting to ensure you are able to see useful error messages.
  • Ensure the database credentials and connection details are valid.
  • Use mysqli_error after mysqli_xxx function calls to detect issues within the mysqli module.
  • Use the @ token sparingly to avoid hiding useful errors.
Community
  • 1
  • 1
Chris Hutchinson
  • 9,082
  • 3
  • 27
  • 33
  • Prefixing the @ token prevents mysqli_connect from reporting an error; remove that and verify that error reporting is enabled: http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php – Chris Hutchinson Apr 14 '15 at 17:42