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
  #1  
Old October 18th, 2002, 03: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, 04: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: 5
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, 04: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: 24
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, 05: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: 24
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, 05: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, 05: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: 5
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, 05: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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway