Mourning the loss of our friend, WhitPhil.
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 audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem recovery router safe mode screen slow sound spyware tdlwsp.dll trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
php does not print first record from mysql database

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
twmprys's Avatar
Computer Specs
Member with 69 posts.
 
Join Date: Jun 2009
Experience: Beginner
07-Nov-2009, 04: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, 04: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 69 posts.
 
Join Date: Jun 2009
Experience: Beginner
07-Nov-2009, 05: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 Bookmark and Share

Smart Search

Find your solution!



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


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 11:31 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.