Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 18th, 2002, 04:44 PM
c0rbin c0rbin is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Houston, TX, USA
Posts: 8 c0rbin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to c0rbin
Problem with Tutorial >> Create dynamic sites with PHP & MySQL by Md. Ashraful Anam

I am using the code from this page:

http://codewalkers.com/tutorials/9/8/

I get the following error when I run it in my browser:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/moontots/public_html/test/viewdb.php on line 8

Here is the code:

>> <HTML>
>> <?php
>> $db = mysql_connect("localhost", "root", "");
>> mysql_select_db("learndb",$db);
>> $result = mysql_query("SELECT * FROM personnel",$db);
>> echo "<TABLE>";
>> echo"<TR><TD><B>Full Name</B><TD><B>Nick Name</B><TD><B>Salary</B></TR>";
>> while($myrow = mysql_fetch_array($result))
>> {
>> echo "<TR><TD>";
>> echo $myrow["firstname"];
>> echo " ";
>> echo $myrow["lastname"];
>> echo "<TD>";
>> echo $myrow["nick"];
>> echo "<TD>";
>> echo $myrow["salary"];
>> }
>> echo "</TABLE>";
>> ?>
>> </HTML>

Reply With Quote
  #2  
Old October 18th, 2002, 05:54 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to notepad
RE: Problem with Tutorial >> Create dynamic sites with PHP & MySQL by Md. Ashraful Anam

do you have anything stored in the database?

Reply With Quote
  #3  
Old October 18th, 2002, 05:59 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: Problem with Tutorial >> Create dynamic sites with PHP & MySQL by Md. Ashraful Anam

Yes I do.

Reply With Quote
  #4  
Old October 18th, 2002, 06:00 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: Problem with Tutorial >> Create dynamic sites with PHP & MySQL by Md. Ashraful Anam

I can view it in a browser using this code:

php Code:
Original - php Code
  1.  
  2. <?php
  3.  
  4.     $dbh=mysql_connect ("localhost", "moontots_tester", "tester") or die ('I cannot connect to the database.');
  5. mysql_select_db ("moontots_") or die("Could not select database");
  6.  
  7.  
  8.  
  9.     /* Performing SQL query */
  10.     $query = "SELECT * FROM testDB";
  11.     $result = mysql_query($query) or die("Query failed");
  12.  
  13.     /* Printing results in HTML */
  14.     print "<table width=50% border=1 cellspacing=0 cellpadding=2>n";
  15.     print "<tr><td>First Name</td><td>Last Name</td><td>Nick</td><td>email</td><td>Salary</td>n";
  16.     while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
  17.         print "t<tr bgcolor=#efefef>n";
  18.         foreach ($line as $col_value) {
  19.             print "tt<td>$col_value</td>n";
  20.         }
  21.         print "t</tr>n";
  22.     }
  23.     print "</table>n";
  24.  
  25.     /* Free resultset */
  26.     mysql_free_result($result);
  27.  
  28.     /* Closing connection */
  29.     mysql_close($dbh);
  30. ?>

Reply With Quote
  #5  
Old October 18th, 2002, 06:03 PM
c0rbin c0rbin is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Houston, TX, USA
Posts: 8 c0rbin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to c0rbin
RE: Problem with Tutorial >> Create dynamic sites with PHP & MySQL by Md. Ashraful Anam

Sorry about the multible posts, I was "Anonymous" now I have loggined in.

Reply With Quote
  #6  
Old October 18th, 2002, 06:33 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to notepad
RE: Problem with Tutorial >> Create dynamic sites with PHP & MySQL by Md. Ashraful Anam

well you've got two different queries there, which one are you using?

SELECT * FROM personnel
or
SELECT * FROM testDB

Reply With Quote
  #7  
Old October 18th, 2002, 06:46 PM
c0rbin c0rbin is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Houston, TX, USA
Posts: 8 c0rbin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to c0rbin
RE: Problem with Tutorial >> Create dynamic sites with PHP & MySQL by Md. Ashraful Anam

Actually, I figured the problem out.

The Table name (testDB) is case sensetive. In the code I was using, I was using testdb, not testDB (The personnel table is from Mr. Anam's tutorial code).

I became case sensetive myself, made the change, and it worked fine.

Thanks for spending thought power on me.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > Problem with Tutorial >> Create dynamic sites with PHP & MySQL by Md. Ashraful Anam


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek