473,513 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Call to a member function free() on a non-object

2 New Member
Call to a member function free() on a non-object error can anyone help plz?
Aug 2 '07 #1
5 6055
howlostami
2 New Member
sorry here,s the code so far :
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  <title>Book-O-Rama Search results</title>
  4. </head>
  5. <body>
  6. <h1>Book-O-Rama Search Results</h1>
  7.  
  8. <?php
  9.   // create short variable names
  10.   $searchtype=$_POST['searchtype'];
  11.   $searchterm=$_POST['searchterm'];
  12.   $searchterm= trim($searchterm);
  13. if (!$searchtype || !$searchterm)
  14. {
  15.    echo 'You have not entered search details. Please go back and try again.';
  16.    exit;
  17. }
  18. if (!get_magic_quotes_gpc())
  19. {
  20.   $searchtype = addslashes($searchtype);
  21.   $searchterm = addslashes($searchterm);
  22. }
  23.  
  24. @ $db = new mysqli('localhost' , 'bookorama' , 'bookorama123' , 'books' );
  25.  
  26. if (mysqli_connect_errno())
  27. {
  28.    echo 'Error: Could not connect to database. Please try again later.' ;
  29.    exit;
  30. }
  31. $query ="select * from books where ".$searchtype."like '%" .$searchterm. "%'" ;
  32. $result = $db->query($query);
  33. $num_results = $result->num_rows;
  34. echo '<p>Number of books found: '.$num_results. '</p>' ;
  35. for ($i=0; $i <$num_results; $i++)
  36. {
  37.    $row = $result->fetch_assoc();
  38.    echo '<p><strong>' .($i+1).' . Title: ';
  39.    echo htmlspecialchars(stripslashes($row['title']));
  40.    echo '</strong><br />Author: ';
  41.    echo stripslashes($row['author']);
  42.    echo '<br />ISBN: ';
  43.    echo stripslashes($row['isbn']);
  44.    echo '<br />Price: ';
  45.    echo stripslashes($row['price']);
  46.    echo '</p>';
  47. }
  48.    $result->free();       <--- error comes up here
  49.    $db->close(); 
  50.  
  51. ?>
  52. </body>
  53. </html>
Aug 2 '07 #2
kovik
1,044 Recognized Expert Top Contributor
It means that you are trying to call a function from an variable that isn't an object -- EXACTLY what it states.

i.e.

[php]$pObj = NULL;
$pObj->free();[/php]

That will produce the same error because $pObj is not actually an object, even though it's variable name would make you think so.
Aug 2 '07 #3
kovik
1,044 Recognized Expert Top Contributor
There is no "free()" function. MySQL resources don't have any functions of their own at all.

Maybe you're after mysql_free_result().
Aug 2 '07 #4
pbmods
5,821 Recognized Expert Expert
Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as, 'please help' actually get FEWER responses?).
Aug 2 '07 #5
pbmods
5,821 Recognized Expert Expert
Merged duplicate threads.
Aug 2 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2670
by: Nimmi Srivastav | last post by:
When I was learning C, I learned that the data type of a function name by itself is a function pointer. For example int someFunction(char* str) { .... }
13
2415
by: Erik Haugen | last post by:
From reading gotw#84 (http://www.gotw.ca/gotw/084.htm), I'm convinced that I should try to make functions nonfriend nonmembers when practical, but then I came across this: Bruce Eckel says about operator overloads in Thinking In C++ (2nd Ed - http://www.codeguru.com/cpp/tic/tic0129.shtml) "In general, if it doesn't make any difference, they...
4
7392
by: 0to60 | last post by:
I don't know if I have that terminology right, but does anyone know if static member functions (or free standing functions for that matter) are any less overhead than actual member functions that operate on an instance of that class? I'm writing a math calculator that responds to real time data and it needs to be FREAKY fast. To minimize...
2
3621
by: joe | last post by:
hi, after reading some articles and faq, i want to clarify myself what's correct(conform to standard) and what's not? or what should be correct but it isn't simply because compilers don't support. (first i compiled them with g++3.x. ERR means compiler will bark, otherwise it does accept it. Then the Comeau C/C++ 4.3.3 comes)
14
1809
by: Ele | last post by:
Given class A and class B: class A { public: void method_for_B_to_call(); .... }; How to make B to call back method_for_B() of A without letting B know the
2
2392
by: dmitry.freitor | last post by:
Why would someone call a non-static provate member function from another non-static member function of the same class via the this pointer? Thanks. DF
3
4000
by: zx.zhangxiong | last post by:
Dear all, I'm puzzled about the usage of class member function. Any help would be appreciated. class Account { ...
8
1918
by: Crash | last post by:
2 Questions, but first Consider this: I'm looking at a C++ class (patterned using the Singleton Design Pattern). It has some public and private operations. It runs quite happily seving the time and date to everybody. The private operations setTheTime() and setTheDate() I require to be called/influenced externally. For instance a class...
8
3326
by: nsharma78 | last post by:
Hi, I have a code as follows: class A { public: void print(){cout << "Magic" << endl;} };
11
2799
by: ziman137 | last post by:
Hi all, I have a question here. What is the rationale behind ISO C++ for Static Member Definition? * ISO C++ forbids in-class definition/initialization of non-constant static member variables. For example, instead of
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7565
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.