Why would a script not like using MySQLi but is fine with MySQL?

Posted by Taylor on Stack Overflow See other posts from Stack Overflow or by Taylor
Published on 2010-02-25T16:04:31Z Indexed on 2010/04/21 22:33 UTC
Read the original article Hit count: 306

Filed under:
|
|

I'm having some issues using mysqli to execute a script with SELECT,DELETE,INSERT and UPDATE querys. They work when using norm mysql such as mysql_connect but im getting strange results when using mysqli. It works fine with a lot of the SELECT querys in other scripts but when it comes to some admin stuff it messes up.

Its difficult to explain without attaching the whole script.

This is the function for modifying...


function database_queryModify($sql,&$insertId)
  {
    global $databaseServer;
    global $databaseName;
    global $databaseUsername;
    global $databasePassword;
    global $databaseDebugMode;

    $link = @mysql_connect($databaseServer,$databaseUsername,$databasePassword);

    @mysql_select_db($databaseName,$link);

    $result = mysql_query($sql,$link);

    if (!$result && $databaseDebugMode)
    {
      print "[".$sql."][".mysql_error()."]";
    }

    $insertId = mysql_insert_id();

    return mysql_affected_rows();
  }

and heres what I changed it to for mysqli


function database_queryModify($sql,&$insertId)
  {
    global $databaseServer;
    global $databaseName;
    global $dbUser_feedadmin;
    global $dbUser_feedadmin_pw;
    global $databaseDebugMode;

    $link = @mysqli_connect($databaseServer,$dbUser_feedadmin,$dbUser_feedadmin_pw,$databaseName);
    $result = mysqli_query($link, $sql);

    if (!$result && $databaseDebugMode)
    {
      print "[".$sql."][".mysqli_error()."]";
    }
    $insertId = mysqli_insert_id();
    return mysqli_affected_rows();
  }

Does that look right?

It isn't actually producing an error but its not functioning in the same way as when using mysql. any ideas?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql