mysqli_fetch_assoc expects parameter 1 to be mysqli_result

Mysqli_fetch_assoc expects parameter 1 to be mysqli_result

I'd move the actual fetch into the class so you wrap the nature of the db more completely Reply to author. Copy link.

The script is basically trying to do a few simple things by connecting to a database and reading off a record, and then getting the results from an array. Once you have it working, you need to use prepared statements instead of just appending strings into your query. Thanks for the reply. The readdb function now looks like this, and at least produces a result:. Thank you for the post; appreciated. For prepared statements, scroll down a bit and browse some threads - there are plenty of examples on here, some in the last few days. But I always have to look up mysqli syntax.

Mysqli_fetch_assoc expects parameter 1 to be mysqli_result

Sign in Email. Forgot your password? Ask a Question. Please Sign up or sign in to vote. See more: SQL. Posted May pm Matas - developer. Add a Solution. You could start by clicking on the numerous links at the right side of this page which relate to this issue :. Richard MacCutchan May am. I think I'm going to be a rich man Accept Solution Reject Solution. Permalink Share this answer. Posted May pm Richard MacCutchan.

Thanks for the reply. Layout: fixed fluid.

.

Doing an assignment for uni, and stuck on an error. Ill attach some files to show the problem and any help very much appreciated. YOu posted an awful lot of c The problem is on LINE Look at it and then figure out why your db connection or your query is failing you. That is the problem. Do you have error checking turned on? Sat Mar 28 Its an attempt to write a discussion forum for an assignment.

Mysqli_fetch_assoc expects parameter 1 to be mysqli_result

Fetches one row of data from the result set and returns it as an associative array. Each subsequent call to this function will return the next row within the result set, or null if there are no more rows. If two or more columns of the result have the same name, the last column will take precedence and overwrite any previous data. Note : Field names returned by this function are case-sensitive. Returns an associative array representing the fetched row, where each key in the array represents the name of one of the result set's columns, null if there are no more rows in the result set, or false on failure. The result set will always be iterated from the first row, regardless of the current position. Submit a Pull Request Report a Bug. Return Values Returns an associative array representing the fetched row, where each key in the array represents the name of one of the result set's columns, null if there are no more rows in the result set, or false on failure. I often like to have my results sent elsewhere in the format of an array although keep in mind that if you just plan on traversing through the array in another part of the script, this extra step is just a waste of time. If two columns of the result have the same column name, even if they are prefixed with different table names in the query, only one of them will be retained in the result.

Best ps4 open world games

Hey, Sorry im still learning php so im not entirely sure what you mean Somthing like this might work better: [code] if! I'd move the actual fetch into the class so you wrap the nature of the db more completely Sign in Email. Update: Ah, figured it out. Accept Solution Reject Solution. Show original message. Showing only the last row I would assume? Report message. Yes, can confirm that my code works okay without the semi-colon in the query. Please Sign up or sign in to vote.

Sign in Email. Forgot your password? Ask a Question.

This email is in use. Treat my content as plain text, not as HTML. Report message. Posted May pm Richard MacCutchan. Once you have it working, you need to use prepared statements instead of just appending strings into your query. Please Sign up or sign in to vote. OK Paste as. See more: SQL. Permalink Share this answer. I personally always opt to leave it out, but to each their own I suppose.

3 thoughts on “Mysqli_fetch_assoc expects parameter 1 to be mysqli_result

Leave a Reply

Your email address will not be published. Required fields are marked *