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
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.
Mysqli_fetch_assoc expects parameter 1 to be mysqli_result
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. Some of my issue had to do with the fact that because I default the ID of the record to 1, when I later try to read the prior record there is none. Also, I have now set the default value of ID as an integer, rather than a string. Update: Ah, figured it out. Thanks for both replies.
For prepared statements, scroll down a bit and browse some threads - there are plenty of examples on here, some in the last few days. Hopefully I wont encounter the same problem again. This email is in use.
.
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. I seem to have managed to print out the main topic headings but failed to display the rest.
Mysqli_fetch_assoc expects parameter 1 to be mysqli_result
This extension was deprecated in PHP 5. Alternatives to this function include:. Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead. It only returns an associative array. Returns an associative array of strings that corresponds to the fetched row, or false if there are no more rows. If two or more columns of the result have the same field names, the last column will take precedence. Note : Field names returned by this function are case-sensitive. Submit a Pull Request Report a Bug. Warning This extension was deprecated in PHP 5.
Blue yellow flag with trident
Treat my content as plain text, not as HTML. Once you have it working, you need to use prepared statements instead of just appending strings into your query. See more: SQL. Richard Deeming. After looking at documentation, it might be that if there is anything between the semicolon and the enclosing quotation marks PHP thinks it is a multi-statement and would error? Hi i'm having a little trouble displaying content from a database Copy link. Mittineague September 20, , pm 9. Thank you again for your previous assistance droopsnoot; I really do appreciate it. Sign in Email. Thanks for the reply. Hopefully I wont encounter the same problem again. But I always have to look up mysqli syntax. I think I'm going to be a rich man For prepared statements, scroll down a bit and browse some threads - there are plenty of examples on here, some in the last few days.
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.
Show original message. Thanks for the reply. It looks to me like it is only catching when your query string is empty, if you want to error check the result in your class then you will have to manually check your DB wrapper error result because it didn't throw an error. Treat my content as plain text, not as HTML. It does pose a question about your classes error handling which looks like it is more the issue because you would have wanted it to catch that. You could start by clicking on the numerous links at the right side of this page which relate to this issue :. I'm sure I just messed something up and cant see it. If anyone can help i would really appreciate it See more: SQL. OK Paste as. The readdb function now looks like this, and at least produces a result:. Showing only the last row I would assume?
In my opinion you are not right. I am assured. Let's discuss it. Write to me in PM.
You have hit the mark. Thought good, I support.