8 Replies - 1238 Views - Last Post: 29 July 2011 - 01:45 PM Rate Topic: -----

#1 sunjava1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 14-May 11

print data on browser from mysql

Posted 29 July 2011 - 09:11 AM

I want to print data from mysql to web-browser window (simple I want to echo) using php.
I do it with
mysql_fetch_array()
with the table I have created. And it works
fine. But when I do this with my forum's table this gives me error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

This is the script I am having problem with my forum's table
<?php
$con1=mysql_connect("hostname","user123","password");

if(!$con1)
{
die("unable to conect mybb: ".mysql_error());
}
mysql_select_db("user123",$con1);
$sub="SELECT * FROM mybb_posts WHERE message LIKE '%smili%'";
$resltsub=mysql_query($sub);
	
		while ($row=mysql_fetch_array($resltsub))
		{
	echo $row[message];
	}
mysql_close($con1);
?>


but the same when I do with my table it works fine. This is the script when I do with my own table
<?php
$con=mysql_connect("hostname","user3241","password");

if(!$con)
{
die("unable to connect mysql: ".msql_error());
}

mysql_select_db("user3241",$con);



$dro="SELECT * FROM person WHERE FirstName LIKE '%opbo%'";
$droe=mysql_query($dro);
while($row=mysql_fetch_array($droe))
{



echo $row[FirstName];

}

mysql_close($con);


?> 


This post has been edited by sunjava1: 29 July 2011 - 09:20 AM


Is This A Good Question/Topic? 0
  • +

Replies To: print data on browser from mysql

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: print data on browser from mysql

Posted 29 July 2011 - 09:27 AM

Read some of the links in the FAQ. This one of the most frequently asked questions for noobs in PHP/MySQL programming.
Was This Post Helpful? 1
  • +
  • -

#3 sunjava1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 14-May 11

Re: print data on browser from mysql

Posted 29 July 2011 - 09:36 AM

can't u tell me the function name or method I will find all by my self
Was This Post Helpful? 0
  • +
  • -

#4 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 947
  • View blog
  • Posts: 2,355
  • Joined: 15-February 11

Re: print data on browser from mysql

Posted 29 July 2011 - 10:06 AM

To be more specific visit this link http://www.dreaminco...32620-php-faqs/ and read #3
Was This Post Helpful? 0
  • +
  • -

#5 sunjava1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 14-May 11

Re: print data on browser from mysql

Posted 29 July 2011 - 10:10 AM

read but solved :(
Was This Post Helpful? 0
  • +
  • -

#6 sunjava1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 14-May 11

Re: print data on browser from mysql

Posted 29 July 2011 - 10:46 AM

This is the solution to the problem. I found it from another website , being a member of Dream in code :9

http://www.codingfor...464&postcount=3
Was This Post Helpful? 0
  • +
  • -

#7 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 947
  • View blog
  • Posts: 2,355
  • Joined: 15-February 11

Re: print data on browser from mysql

Posted 29 July 2011 - 11:20 AM

Verify that you didn't misspell any table names in your query. Does mysql_select_db return true?
Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: print data on browser from mysql

Posted 29 July 2011 - 01:33 PM

So, in other words, you didn't bother to read the links provided, or search this forum, but you managed to search another site and find the information? Because that information is provided:

1. in the link provided above (specifically the one pointed to by codeprada)
2. in this tutorial
3. in the documentation
Was This Post Helpful? 0
  • +
  • -

#9 sunjava1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 14-May 11

Re: print data on browser from mysql

Posted 29 July 2011 - 01:45 PM

There is nothing like searching and reading, the link provided only tells not show demonstration. I just search my question on search engine and it nicely navigate me to the post. anyways thanks

This post has been edited by sunjava1: 29 July 2011 - 01:48 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1