When I do a print_r, I get a number 1 between the array blocks. I have no idea where it is coming from.
This is causing errors in my log. I can fix this by testing with is_array but I want to know where this is coming from.
I'm making two queries but yet I have a third array in there. What is going on?????
mysqli_result Object
(
[current_field] => 0
[field_count] => 2
[lengths] =>
[num_rows] => 110
[type] => 0
)
mysqli_result Object
(
[current_field] => 0
[field_count] => 1
[lengths] =>
[num_rows] => 12
[type] => 0
)
1 <-------------------------------------HERE
mysqli_result Object
开发者_Go百科(
[current_field] => 0
[field_count] => 1
[lengths] =>
[num_rows] => 1
[type] => 0
)
$this->conn->query("CALL phoneIsRegistered($phone,@phone)");
$res = $this->conn->query("SELECT @phone");
$result = mysqli_query($this->conn, $query) or die('Error: '.mysqli_error($this->conn));
if($result)
{
while($row = $result->fetch_object())
{
if($row)
{
print_r($row);
}
}
$this->disconnect();
}
This is what the loop looked like before I began trying to find this.
$this->connect();
$result = mysqli_query($this->_conn, $query) or die('Error: '.mysqli_error($this->conn));
if($result){
$i=0;
$res = array();
while($row = $result->fetch_object()){
if($row){
$res[$i++] = $row;
}
}
$this->disconnect();
return $res;
}else{
return false;
}
I'll bet you a beer that at some point while adding those mysqli_results to your array, you are pushing a true
value into the array, maybe when the variable you work on turns out not to be a valid mysql_result or due to some other misdirected check or comparison.
You would have to show us the complete loop you are using to fill the array.
Whenever I am using print_r I see these 1's come up a lot also. I believe that this page would answer your question.
Number Appears after Array Stored in SESSION
It should not hurt anything....
Beside using print_r
or vardump
, you should consider using FirePHP or PHP Quick Profiler to help you debugging and displaying variable's value.
With FirePHP, you can display the value into Firebug's console. Using, PHP Quick Profiler, there will be a console added at the bottom of the page that can be used to display any value that you need.
精彩评论