?
Solved

Getting error that does not match code

Posted on 2016-07-21
6
Medium Priority
?
47 Views
Last Modified: 2016-07-21
Here is the code from the page:

      echo "fred";
      $SqlString1 = "SELECT * FROM survey_data WHERE SEQ like \"".$strt."%\" and CITY != \"\" and STAT != \"\" and ZIP != \"\"";
      $survey_data = $conn->query($SqlString1);
      $row_survey_data = $survey_data->fetch();

This is the display from the page:
fred
Fatal error: Call to undefined method mysqli_result::fetch() in /home/langsyst/public_html/Lansco/Update_Building.php on line 54

Line 54 is the $row_survey_data fetch

Where the hell is it getting "mysqli"?
0
Comment
Question by:breeze351
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 41723621
the connection object you are using is using mysqli under the hood
hence, you need to use fetch_row or fetch_all
http://php.net/manual/en/class.mysqli-result.php
1
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41723622
That often means your query above it did not succeed.  'mysqli_result::fetch' is the name of the actual function used by fetch() with the 'mysqli' driver.  http://php.net/manual/en/mysqli-stmt.fetch.php
1
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 41723633
That error is the often the signal taht the query fails: try to run the query in phpMyAdmin (or equivalent) and see what's happen.
 Also you should use mysqli_error( $conn ); to get the error:
      echo "fred";
      $SqlString1 = "SELECT * FROM survey_data WHERE SEQ like \"".$strt."%\" and CITY != \"\" and STAT != \"\" and ZIP != \"\"";
      echo $SqlString1 . '<br>';
      $survey_data = $conn->query($SqlString1);
      if ($survey_data){
           $row_survey_data = $survey_data->fetch();
     }else{
         echo mysqli_error( $conn );
     }

Open in new window

0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 111

Expert Comment

by:Ray Paseur
ID: 41723634
How to use the MySQL extensions, including:
  1. Conversion from MySQL to modern extensions
  2. How to test for query success or failure and visualize any errors
  3. How to retrieve results
  4. How to avoid trip-wires such as mixing procedural and object-oriented code
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

The article includes tested-and-working code examples you can copy for your own use.
0
 

Author Closing Comment

by:breeze351
ID: 41723659
Sometimes I'm a moron.  Changed it to fetch_array() and it worked.  Stared at this all afternoon!!!
Thanks
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 41723672
Fetch_Array() is an anti-pattern.  Unless you deliberately tell it otherwise, It returns twice as much information as needed, making it the least efficient way to acquire information from the results set.

in my experience, the best function (correct amount of data, easy-to-use syntax) is Fetch_Object()
0

Featured Post

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question