FIXED: expects parameter 1 to be resource, boolean given

Problems with the Windows version of XAMPP, questions, comments, and anything related.

FIXED: expects parameter 1 to be resource, boolean given

Postby hempseed » 26. November 2009 18:11

Hi
I'm using 1.7.2. and I got a problem in my coding, I'm very fresh in coding,but I try this code in the old version before, it works! But can't work in the new version.
Code: Select all
<?php

   $conn = mysql_connect("localhost","root","");
   
   mysql_select_db("userdb");
   
   $result = mysql_query("select * from tb_book",$conn);
   
   echo "<table border=1><tr>";
   
   if($field = mysql_fetch_field($result)){
      echo "<td>&nbsp;".$field->name."&nbsp;</td>";
   }
   echo "</tr>";
   if($rows = mysql_fetch_row($result)){
      echo "<tr>";
      for($i=0; $i<count($rows);$i++)
      echo "<td>&nbsp;".$rows[$i]."</td>";
   }
      echo "</tr></table>";
?>



Warning: mysql_fetch_field() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sql\1.php on line 26


Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sql\1.php on line 30

the db connection is fine, how can i fix this problem?

many thanks

hempseed
Last edited by hempseed on 26. November 2009 19:43, edited 1 time in total.
hempseed
 
Posts: 2
Joined: 26. November 2009 18:00

Re: problems: expects parameter 1 to be resource, boolean given

Postby Wiedmann » 26. November 2009 18:36

the db connection is fine,

How can you know this, because you don't test this?

Warning: mysql_fetch_field() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sql\1.php on line 26

There is something wrong with your query (or your connection).
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: problems: expects parameter 1 to be resource, boolean given

Postby hempseed » 26. November 2009 19:43

thanks for your reply.
I fixed it after i delete another application. thanks a lot
hempseed
 
Posts: 2
Joined: 26. November 2009 18:00


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 64 guests