Current location: Hot Scripts Forums » Programming Languages » PHP » mysqli_fetch_assoc() expects parameter 1 to be mysqli_result,


mysqli_fetch_assoc() expects parameter 1 to be mysqli_result,

Reply
  #1 (permalink)  
Old 10-27-07, 07:04 AM
ausgezeichnete's Avatar
ausgezeichnete ausgezeichnete is offline
Wannabe Coder
 
Join Date: Oct 2007
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation mysqli_fetch_assoc() expects parameter 1 to be mysqli_result,

Hello There
i got this error with my script and i dont know why???????


PHP Code:

<html>

<
head>
<
title>
Welcome to the search Page
</title>
</
head>
<
body>
<
form action="2.php" method="post">
Search:
<
input type="text" name="search" >
<
input type="submit" name="submit" >
</
form>
</
body>
</
html
PHP Code:



<?php
    
//connect to database server and select a database called cars
    
$conn mysql_connect("localhost""root""");
    
mysql_select_db("cars",$conn);
    
$query"select * from cartable where name like '%".$search."%'";
    
$result=mysql_query($query);
    if(
$result === false) {
die(
mysqli_error());
}
    while(
$record=mysqli_fetch_assoc($result)){
    
    while(list(
$name,$value)=each($record)){
        echo 
$name.$value;
    }
echo 
"</br>";
}
Reply With Quote
  #2 (permalink)  
Old 10-27-07, 07:14 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
You're mixing mysql with mysqli.

Replace all mysqli_* occurrences with the appropriate mysql_* equivalent.
Reply With Quote
  #3 (permalink)  
Old 10-27-07, 07:33 AM
ausgezeichnete's Avatar
ausgezeichnete ausgezeichnete is offline
Wannabe Coder
 
Join Date: Oct 2007
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation i did!!!!!!!!!!!!!!!!!1

and it gave me that:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\wamp\www\Maha\2.php on line 8
Reply With Quote
  #4 (permalink)  
Old 10-27-07, 08:09 AM
ausgezeichnete's Avatar
ausgezeichnete ausgezeichnete is offline
Wannabe Coder
 
Join Date: Oct 2007
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
no it worked now thnxxxxx
PHP Code:

<?php
    
//connect to database server and select a database called cars
    
$conn mysqli_connect("localhost""root""","cars");
    
    
$query"select * from cartable where make like '%".$search."%'";
    
$result=mysqli_query($conn,$query);
    if (!
$result) {
    die(
'Could not query:' mysql_error());
}

    while(
$record=mysqli_fetch_assoc($result)){
    
    while(list(
$name,$value)=each($record)){
        echo 
$name.":".$value."</br>";
    }
echo 
"</br>";
}    
    
?>
    
    <a href="1.php">Back</a>

Last edited by Nico; 10-27-07 at 08:24 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fatal error: Cannot pass parameter 1 by reference moonncloud PHP 3 06-16-07 02:04 PM
mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given pr0grammer PHP 2 05-21-07 01:13 AM
Warning: Wrong parameter count for mysql_error() deeps_ar PHP 1 04-05-06 12:58 PM
Warning: Wrong parameter count... Tim Mousel PHP 5 01-23-06 12:10 PM
Wrong parameter count for mysql_fetch_assoc() altlprsn PHP 1 05-26-04 09:40 PM


All times are GMT -5. The time now is 07:31 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.