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. Report message.

Sign in Email. Forgot your password? Ask a Question. Please Sign up or sign in to vote. See more: SQL.

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. Yes, can confirm that my code works okay without the semi-colon in the query. Thank you again for your previous assistance droopsnoot; I really do appreciate it. 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? I personally always opt to leave it out, but to each their own I suppose.

Somthing like this might work better: [code] if!

.

W3Schools offers a wide range of services and products for beginners and professionals, helping millions of people everyday to learn and master new skills. Create your own website with W3Schools Spaces - no setup required. Host your own website, and share it to the world with W3Schools Spaces. Build fast and responsive sites using our free W3. CSS framework. W3Schools Coding Game! Help the lynx collect pine cones. If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:.

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.

Hair dryer jb hifi

Steve Wake. Please Sign up or sign in to vote. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. I'd move the actual fetch into the class so you wrap the nature of the db more completely Hi i'm having a little trouble displaying content from a database You could start by clicking on the numerous links at the right side of this page which relate to this issue :. Add your solution here. Copy link. Best guess. Report message. Related Questions.

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.

Forgot your password? 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. See more: SQL. For prepared statements, scroll down a bit and browse some threads - there are plenty of examples on here, some in the last few days. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. I wrote that class while studying and havent really revised it since Related Questions. Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message. This topic was automatically closed 91 days after the last reply. Yes, can confirm that my code works okay without the semi-colon in the query. Don't tell someone to read the manual. Let's work to help developers, not make them feel stupid. Lol it was a typo wasn't it? When answering a question please: Read the question carefully.

1 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 *