Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysqli_stmt_bind_result unexpected behavior on MAC versus PC

Status
Not open for further replies.

justride

Programmer
Jan 9, 2004
251
0
0
US
Using XAMMP or WAMMP on my MAC, I am seeing some odd behavior when attempting to retrieve some values from a BIGINT(10) MYSQL field, and I can only assume its the MYSQL bind or PHP echo, the same code works fine on a PC.

Code:
$stmt = mysqli_prepare($this->connection, "SELECT USER_ID, USER_NAME, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, PHONE_EXTENSION FROM `USER` WHERE `USER_ID` = '".$userId."' LIMIT 1;");
		mysqli_stmt_execute($stmt);

		mysqli_stmt_bind_result($stmt, $row->USER_ID, $row->USER_NAME, $row->FIRST_NAME, $row->LAST_NAME, $row->EMAIL, $row->PHONE_NUMBER, $row->PHONE_EXTENSION);

when I echo the $row[0]->PHONE_NUMBER or $row[0]->PHONE_EXTENSION in XAMPP on MAC or WAMMP on MAC the browser renders "%qd"

This same code/schema on windows renders the numbers normally.

Thoughts? Should I have any other concerns?

Thanks
 
I'm surprised that it renders anything to be honest. and I do not see how this could work on windows either.

I assume that there is a good reason for using mysqli in your case (I have rarely found one) and I also assume that there is a good reason for binding your results rather than just fetching the row.

If you must proceed in the manner of your code I think the minimum I would add would be to instantiate the $row object before binding to it and then to issue an explicit fetch. and even then I'm not sure that it would work the way you intend.

Code:
$row = new stdclass;
mysqli_stmt_bind_result(...);
mysqli_stmt_fetch($stmt)

My understanding of the way that mysqli works is that the data would then be in the $row object and not the $row[0] object (whatever that might be).

but surely a simple fetch is somewhat easier and eliminates the need for binding altogether?
Code:
mysql_stmt_fetch_object($stmt);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top