There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Web Design & Development
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard netgear network printer problem ram registry repair router slow software sound toshiba trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
php does not print first record from mysql database

Reply  
Thread Tools
twmprys's Avatar
Computer Specs
Member with 106 posts.
 
Join Date: Jun 2009
Experience: Beginner
07-Nov-2009, 05:23 PM #1
php does not print first record from mysql database
Another problem from the mad, mad world of php. I've got just a simple php SELECT and WHILE loop to ECHO contents of a MySQL database, but the first record does not appear! What one earth can be going on? Any suggestions greatly appreciated!

PHP Code:
<?php
mysql_connect
("host""name""password") or die(mysql_error()); 
mysql_select_db("database") or die(mysql_error());
$query "SELECT * FROM newsletter WHERE number='33' ORDER BY id";
$result mysql_query($query) or die(mysql_error()); 
$row mysql_fetch_array($result) or die(mysql_error());
while(
$row mysql_fetch_array$result )) {
echo 
nl2br($row['headline']) . '<br>';
echo 
nl2br($row['story']) . '<br>';
}
?>
midders's Avatar
Account Closed with 654 posts.
 
Join Date: Dec 1969
07-Nov-2009, 05:57 PM #2
Code:
$row = mysql_fetch_array($result) or die(mysql_error()); 
while($row = mysql_fetch_array( $result )) {
You are discarding the first row of the result with the first line above; just omit this and it will work fine.

Slainte

midders
twmprys's Avatar
Computer Specs
Member with 106 posts.
 
Join Date: Jun 2009
Experience: Beginner
07-Nov-2009, 06:17 PM #3
How silly of me! That's what great about this Tech Support Guy site - people are prepared to help you out with almost anything!

Go raibh maith agat!
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:09 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.