Web Design Forum: code showing error - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

code showing error Rate Topic: -----

#1 User is offline   lee sands 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 134
  • Joined: 14-August 10
  • Reputation: 0
  • Gender:Male
  • Location:Gosport, Hampshire, UK
  • Experience:Beginner
  • Area of Expertise:Coder

Posted 14 January 2012 - 02:31 PM

	print '<div class="small-border"><ul>';
		$sql = "SELECT * FROM cms_catergories";
		$result = mysql_query($sql,$conn);
		
		while($row = mysql_fetch_array($result)) {
			print '<li> <a href = "catergoy.php?c='.$row['cat_id'].'">'.$row['cat_name'].'</a></li>';
		}
		print '</ul></div>';


this code works fine on its own but when imported it shows

Quote

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\cms\library\cats.php on line 8

0

#2 User is offline   webdesigner93 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,976
  • Joined: 22-September 09
  • Reputation: 222
  • Gender:Male
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 14 January 2012 - 04:29 PM

View Postlee sands, on 14 January 2012 - 02:31 PM, said:

	print '<div class="small-border"><ul>';
		$sql = "SELECT * FROM cms_catergories";
		$result = mysql_query($sql,$conn);
		
		while($row = mysql_fetch_array($result)) {
			print '<li> <a href = "catergoy.php?c='.$row['cat_id'].'">'.$row['cat_name'].'</a></li>';
		}
		print '</ul></div>';


this code works fine on its own but when imported it shows


try seeing what $result outputs

echo var_dump($result);

0

#3 User is offline   GalaxyTramp 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 120
  • Joined: 09-December 11
  • Reputation: 16
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 14 January 2012 - 04:32 PM

View Postlee sands, on 14 January 2012 - 02:31 PM, said:

	print '<div class="small-border"><ul>';
		$sql = "SELECT * FROM cms_catergories";
		$result = mysql_query($sql,$conn);
		
		while($row = mysql_fetch_array($result)) {
			print '<li> <a href = "catergoy.php?c='.$row['cat_id'].'">'.$row['cat_name'].'</a></li>';
		}
		print '</ul></div>';


this code works fine on its own but when imported it shows


The error code shows that the problem lies with line 8 of the cats.php page. Which line of your code is this?

Not sure what you mean when you say "this code works fine on its own but when imported it shows" the error.

Your problem is that your query is failing so I would suspect that the $conn variable is incorrect on the "imported" machine.

Add $result = mysql_query($sql,$conn)or die('There has been an error' . mysql_error()); to your query to get exact error

Colin
0

#4 User is offline   lee sands 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 134
  • Joined: 14-August 10
  • Reputation: 0
  • Gender:Male
  • Location:Gosport, Hampshire, UK
  • Experience:Beginner
  • Area of Expertise:Coder

Posted 14 January 2012 - 06:40 PM

all sorted it was a pice of code that was not being showed lol i have a new problem with mysql joins
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users