Re: MySQLI, Class not found

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	Hi,

    One thing i see is the use of num_rows on mysqli_result class,
but num_rows is member or mysqli class and not mysqli_result.
    Perhaps this call to num_rows corrupts the rest.
    Other than that everything seems fine.
    Perhaps you should consider linux :), much better choice for web server
anyway.
    Try adding error_reporting(E_ALL); at the beginning of the script.
    Btw! you should disable from php.ini the magic quotes; it's a real pain.

Catalin


Esteamedpw@xxxxxxx wrote:
> when i try it this way:
>  
> <?php
>  
> // create short variable  names
> $searchtype=$_POST['searchtype'];
> $searchtype=$_POST['searchterm'];
>  
> $searchterm=trim($searchterm);
>  
> if (!$searchtype || !$searchterm)
> {
> echo 'You have not entered  search details. Please go back and try again.';
> exit;
> }
>  
> if  (!get_magic_quotes_gpc())
> {
> $searchtype=addslashes($searchtype);
> $searchterm=addslashes($searchterm);
> }
>  
> $db = new mysqli('localhost', 'root', 'root', 'bookorama');
>  
>  
>  
> if(mysqli_connect_errno())
> {
> echo 'Error: Could not connect to  the Database. Please try again later.';
> exit;
> }
>  
> $query = "select * from books where ".$searchtype." like  
> '%".$searchterm."%'";
> $result = $db->query($query);
>  
> $num_results = $result->num_rows;
>  
> echo '<p>Number of books found: '.$num_results.'</p>';
>  
> for ($i=0; $i <$num_results; $i++)
> {
> $row =  $result->fetch_assoc();
> echo '<p><strong>'.($i+1).'.  Title: ';
> echo  htmlspecialchars(stripslashes($row['title']));
> echo  '</strong><br />Author: ';
> echo  stripslashes($row['author']);
> echo '<br />ISBN: ';
> echo  stripslashes($row['isbn']);
> echo '<br />Price: ';
> echo  stripslashes($row['price']);
> echo  '</p>';
> }
> var_export($result);
> $result->free();
> $db->close();
>  
> ?>
>  
> It doesn't even try searching the database... it gives me  the:  'You have 
> not entered search details. Please go back and try  again. Error.
>  
> when i comment out the IF statement and add the  var_export($result) (just to 
> see what it happens) it gives me this  error:
>  
> ===============================================
> Number of books found: false
> Fatal error: Call to a  member function free() on a non-object in 
> c:\wamp\www\books\results.php  on line 56 
> ===============================================
>  
> the HTML code is:
>  
> ===============================================
> <form action="results.php" method="post">
> Choose Search  Type: <br />
> <select  name="searchtype">
> <option  value="author">Author</option>
> <option  value="title">Title</option>
> <option  value="isbn">ISBN</option>
> </select>
> <br  />
> Enter Search Term:<br />
> <input  name="searchterm" type="text">
> <br />
> <input  type="submit"  value="Search">
> </form>
> ================================================
>  
> maybe i'm just tired and not seeing something - but i've looked a thousand  
> times and i have no clue why it's doing this... searches on google prove 
> nothing  either.
>  
> Server Configuration 
>     Apache version : Apache/1.3.33 (Win32) (WIN XP)  PHP version : 5.0.4  
> MySQL version :  
> 5.0.7-beta-nt - extension : mysqli
>  
> Thanks again,
>  
> Clint
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux