PHP & MySQL Error - An error occurred on line 176:

2019-08-18 14:50发布

问题:

I was wondering what is causing this error and how can I correct this problem?

Line 176 is below.

$q = "INSERT INTO users (first_name, middle_name, ".
      "last_name, rn, username, month, day, year, se, pic, ".
      "salt, password, rb, aa, ul, rd, ll, ui) ".
      "VALUES ('" . $fn . "', NULL, '" . $ln . "', NULL, '" . 
      $u . "', NULL, NULL, NULL, NULL, NULL, '" . $salt . "', '" . 
      $p . "', '" . $r . "', '" . $ag . "', 0, NOW(), NULL, '" . 
      $unique_id . "')";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " .
         mysqli_error($dbc));

回答1:

One of the variables you are injecting into that query string must be a result from an earlier query.

It's probably the $r.



回答2:

Does the code following line 176 resemble this posters code? If so, try changing it to resemble more of what comes beneath it.

http://www.phpfreaks.com/forums/php-coding-help/(solved)-catchable-fatal-error-object-of-class-mysqli_result-could-not-be-conver/



回答3:

I suspect you're trying to concatenate an object-variable. This is not possible with objects of the class "mysqli_result".

Do a var_dump() on each variable you concatenate to make $q and you'll find out which one it is.



标签: php mysqli