mysqli - how to change mysql_query to mysqli_guery -


i using in script mysqli_query think there wrong syntaxes. script did work before, changing form mysql_query mysqli_query, data not put anymore correct in database.

this original query:

mysql_query(     "insert download_manager (set filename='".mysqli_real_escape_string($_get['file'])."'),                 on duplicate key update downloads=downloads+1"); 

i changed mysqli_query way:

mysqli_query($link, "insert download_manager (set filename='".mysqli_real_escape_string($_get['file'])."'),                 on duplicate key update downloads=downloads+1"); 

can tell me did wrong?

update: connection looks this:

$link = @mysqli_connect($db_host, $db_user, $db_pass, $db_database) or die ("error " . mysqli_error($link));  mysql_set_charset('utf8'); 

ensure handle stored in $link generated call mysqli_connect , not mysql_connect:

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

if fails, check error:

die(mysqli_error($link)) 

troubleshooting

  • the mysql , mysqli php modules distinct, , can't mix functions between modules.
  • enable error reporting ensure able see useful error messages.
  • ensure database credentials , connection details valid.
  • use mysqli_error after mysqli_xxx function calls detect issues within mysqli module.
  • use @ token sparingly avoid hiding useful errors.

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -