473,413 Members | 2,043 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

what do you think, why that?

it only displays the name, but the last name and the address seems not
to exist! why?

<?php
@ $db=mysql_pconnect('host', 'UserID', 'PWD');
if (!$db)
{
echo 'conneciton eror';
exit;
}
else
{
echo 'connection on!';
}
mysql_select_db('list');
$query="select * from index";
$result=mysql_query($query);
$num_results=mysql_num_rows($result);
if ($num_results == 0)
{
echo'<br><br>nothing to dispaly';
}
else
{
echo'<br><br>here are the results: '.$num_results;
}
for ($i<0; $i<$num_results; $i++)
{
$row=mysql_fetch_array($result);
echo '<br>name: ';
echo htmlspecialchars(stripslashes($row['name']));
echo '<br>last name: ';
echo htmlspecialchars(stripslashes($row['last']));
}
?>

Jun 4 '07 #1
5 1257
vinnie wrote:
it only displays the name, but the last name and the address seems not
to exist! why?
echo '<br>name: ';
echo htmlspecialchars(stripslashes($row['name']));
echo '<br>last name: ';
echo htmlspecialchars(stripslashes($row['last']));
Because you tell the script to display the name, not the adres

try var_dump($row); to see what's in the row
Jun 4 '07 #2
vinnie wrote:
it only displays the name, but the last name and the address seems not
to exist! why?

<?php
@ $db=mysql_pconnect('host', 'UserID', 'PWD');
if (!$db)
{
echo 'conneciton eror';
exit;
}
else
{
echo 'connection on!';
}
mysql_select_db('list');
$query="select * from index";
$result=mysql_query($query);
$num_results=mysql_num_rows($result);
if ($num_results == 0)
{
echo'<br><br>nothing to dispaly';
}
else
{
echo'<br><br>here are the results: '.$num_results;
}
for ($i<0; $i<$num_results; $i++)
{
$row=mysql_fetch_array($result);
echo '<br>name: ';
echo htmlspecialchars(stripslashes($row['name']));
echo '<br>last name: ';
echo htmlspecialchars(stripslashes($row['last']));
}
?>
You don't seem to be printing address anywhere. As for last name, check
the name of the column in your table (index).

And, to avoid notices, the code

for ($i<0; $i<$num_results; $i++)

should be

for ($i=0; $i<$num_results; $i++)
Although I would probably write something like

while ($row = mysql_fetch_array($result))
{
....
}
Jun 4 '07 #3
On Jun 4, 5:53 pm, Denis Gerina <denisREMOVET...@cced.bawrote:
vinnie wrote:
it only displays the name, but the last name and the address seems not
to exist! why?
<?php
@ $db=mysql_pconnect('host', 'UserID', 'PWD');
if (!$db)
{
echo 'conneciton eror';
exit;
}
else
{
echo 'connection on!';
}
mysql_select_db('list');
$query="select * from index";
$result=mysql_query($query);
$num_results=mysql_num_rows($result);
if ($num_results == 0)
{
echo'<br><br>nothing to dispaly';
}
else
{
echo'<br><br>here are the results: '.$num_results;
}
for ($i<0; $i<$num_results; $i++)
{
$row=mysql_fetch_array($result);
echo '<br>name: ';
echo htmlspecialchars(stripslashes($row['name']));
echo '<br>last name: ';
echo htmlspecialchars(stripslashes($row['last']));
}
?>

You don't seem to be printing address anywhere. As for last name, check
the name of the column in your table (index).

And, to avoid notices, the code

for ($i<0; $i<$num_results; $i++)

should be

for ($i=0; $i<$num_results; $i++)

Although I would probably write something like

while ($row = mysql_fetch_array($result))
{
...

}
See, and I would avoid the inevitable out of bounds on that with:
while( ($row = mysql_fetch_array($result)) != null)
{

So as not to be operating on a null on the last iteration of the loop.
Agree with the while, though.

~A!

Jun 5 '07 #4
my*************@gmail.com wrote:
On Jun 4, 5:53 pm, Denis Gerina <denisREMOVET...@cced.bawrote:
>vinnie wrote:
>>it only displays the name, but the last name and the address seems not
to exist! why?
<?php
@ $db=mysql_pconnect('host', 'UserID', 'PWD');
if (!$db)
{
echo 'conneciton eror';
exit;
}
else
{
echo 'connection on!';
}
mysql_select_db('list');
$query="select * from index";
$result=mysql_query($query);
$num_results=mysql_num_rows($result);
if ($num_results == 0)
{
echo'<br><br>nothing to dispaly';
}
else
{
echo'<br><br>here are the results: '.$num_results;
}
for ($i<0; $i<$num_results; $i++)
{
$row=mysql_fetch_array($result);
echo '<br>name: ';
echo htmlspecialchars(stripslashes($row['name']));
echo '<br>last name: ';
echo htmlspecialchars(stripslashes($row['last']));
}
?>
You don't seem to be printing address anywhere. As for last name, check
the name of the column in your table (index).

And, to avoid notices, the code

for ($i<0; $i<$num_results; $i++)

should be

for ($i=0; $i<$num_results; $i++)

Although I would probably write something like

while ($row = mysql_fetch_array($result))
{
...

}

See, and I would avoid the inevitable out of bounds on that with:
while( ($row = mysql_fetch_array($result)) != null)
{

So as not to be operating on a null on the last iteration of the loop.
Agree with the while, though.

~A!
Interesting. Do explain, please, in light of the docs.
http://www.php.net/mysql_fetch_array

Returns an array of strings that corresponds to the fetched row, or
FALSE if there are no more rows.

Jun 5 '07 #5
my*************@gmail.com wrote:
On Jun 4, 5:53 pm, Denis Gerina <denisREMOVET...@cced.bawrote:
>vinnie wrote:
>>it only displays the name, but the last name and the address seems not
to exist! why?
<?php
@ $db=mysql_pconnect('host', 'UserID', 'PWD');
if (!$db)
{
echo 'conneciton eror';
exit;
}
else
{
echo 'connection on!';
}
mysql_select_db('list');
$query="select * from index";
$result=mysql_query($query);
$num_results=mysql_num_rows($result);
if ($num_results == 0)
{
echo'<br><br>nothing to dispaly';
}
else
{
echo'<br><br>here are the results: '.$num_results;
}
for ($i<0; $i<$num_results; $i++)
{
$row=mysql_fetch_array($result);
echo '<br>name: ';
echo htmlspecialchars(stripslashes($row['name']));
echo '<br>last name: ';
echo htmlspecialchars(stripslashes($row['last']));
}
?>
You don't seem to be printing address anywhere. As for last name, check
the name of the column in your table (index).

And, to avoid notices, the code

for ($i<0; $i<$num_results; $i++)

should be

for ($i=0; $i<$num_results; $i++)

Although I would probably write something like

while ($row = mysql_fetch_array($result))
{
...

}

See, and I would avoid the inevitable out of bounds on that with:
while( ($row = mysql_fetch_array($result)) != null)
{

So as not to be operating on a null on the last iteration of the loop.
Agree with the while, though.

~A!
Denis's code is correct. There will be no out of bounds error in Denis's
code.

mysql_fetch_array() is a function which returns either an array or
false. It does not return null. Denis's code will continue to fetch
rows as long as the exist; after the last row has been fetched, the next
call to mysql_fetch_array() returns false, stopping the loop.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 5 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: Brandon J. Van Every | last post by:
What do you think of this Python logo? http://pythonology.org/logos Good, bad, indifferent, love it, hate it? -- Cheers, www.indiegamedesign.com Brandon Van Every ...
17
by: owen | last post by:
Your opinion please! Do end-users know, think they know, or even care, what .NET is.? Do customers hear the word ".NET" and think its the latest thing and must only have .NET applications,...
3
by: Jim Douglas | last post by:
With .NET becoming the right tool to use now what do you think is going to be the next great development technology? Thanks! -- Jim Douglas www.genesis-software.com
86
by: Randy Yates | last post by:
In Harbison and Steele's text (fourth edition, p.111) it is stated, The C language does not specify the range of integers that the integral types will represent, except ot say that type int may...
17
by: owen | last post by:
Your opinion please! Do end-users know, think they know, or even care, what .NET is.? Do customers hear the word ".NET" and think its the latest thing and must only have .NET applications,...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.