By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,831 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,831 IT Pros & Developers. It's quick & easy.

PHP.INI Question - Maybe

P: n/a
I am running the same PHP code on two different web site hosts. One
runs this particular snipet of code perfectly, the other gives me
errors.

<?php

// Request the text of all the schools
$query = 'SELECT * FROM members';
$result = mysql_query('SELECT * FROM members');
$num_results=mysql_num_rows($result);
if (!$result)
{
echo "Error performing query: ";
echo mysql_error();
exit();
}
//echo $num_results;
echo("<P> There are ".$num_results." members in our database: </P>");
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo("<P>" . $row[1] ." ". $row[2] . "</P>");
}
?>

Like I said, on one host I get a list of my data, the other I get this
error:

Here are all the customers in our database:

There are ".$num_results." members in our database:

"); for ($i=0; $i < $num_results; $i++) { $row =
mysql_fetch_array($result); echo('
' . $row[1] .' '. $row[2] . '

'); } ?>

Is this because of a setting in my PHP.INI file? Is it not
recognizing the periods between strings?
Jul 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
I noticed that Message-ID:
<21**************************@posting.google.com > from Michael Jones
contained the following:

Is this because of a setting in my PHP.INI file? Is it not
recognizing the periods between strings?


According to the manual there are some issues with exit(). Try removing
it and see what happens.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
Geoff Berrow wrote:
I noticed that Message-ID:
<21**************************@posting.google.com > from Michael Jones
contained the following:

Is this because of a setting in my PHP.INI file? Is it not
recognizing the periods between strings?


According to the manual there are some issues with exit(). Try removing
it and see what happens.


Instead of exit(); you can use die();

Jul 17 '05 #3

P: n/a
I noticed that Message-ID: <2Y5Hc.44775$Oq2.16353@attbi_s52> from Mudge
contained the following:
According to the manual there are some issues with exit(). Try removing
it and see what happens.


Instead of exit(); you can use die();


He could try that, after determining that exit() is the problem.

But as an alias, might it not have the same problem?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4

P: n/a
Geoff Berrow wrote:
I noticed that Message-ID: <2Y5Hc.44775$Oq2.16353@attbi_s52> from Mudge
contained the following:
According to the manual there are some issues with exit(). Try removing
it and see what happens.


Instead of exit(); you can use die();


He could try that, after determining that exit() is the problem.

But as an alias, might it not have the same problem?


I forgot that it was an alias.
Jul 17 '05 #5

P: n/a
I removed the exit(); and I still get the same output.

Isn't this error related to the periods in my ECHO string?

Mudge <ma******@hotmail.com> wrote in message news:<Ym6Hc.44879$Oq2.37840@attbi_s52>...
Geoff Berrow wrote:
I noticed that Message-ID: <2Y5Hc.44775$Oq2.16353@attbi_s52> from Mudge
contained the following:
According to the manual there are some issues with exit(). Try removing
it and see what happens.

Instead of exit(); you can use die();


He could try that, after determining that exit() is the problem.

But as an alias, might it not have the same problem?


I forgot that it was an alias.

Jul 17 '05 #6

P: n/a
"Michael Jones" <mi*****************@yahoo.com> wrote in message
news:21**************************@posting.google.c om...
I am running the same PHP code on two different web site hosts. One
runs this particular snipet of code perfectly, the other gives me
errors.

<?php

// Request the text of all the schools
$query = 'SELECT * FROM members';
$result = mysql_query('SELECT * FROM members');
$num_results=mysql_num_rows($result);
if (!$result)
You are attempting to use a mysql result before checking to see if the query
was successful.

try

$result = mysql_query('SELECT * FROM members');
if (!$result || mysql_error() || mysql_num_rows($result) < 1)
{
// error handling here
}
else
{
$num_results = mysql_num_rows($result);
}

This means you'll have to call mysql_num_rows twice but it's worth it to
avoid any error messages being generated by the underlying software.

Alternatively you can suppress the error message from
$num_results=mysql_num_rows($result);


by using the @ as a suppressor

$num_results = @mysql_num_rows($result);

Jul 17 '05 #7

P: n/a
In message-id <21**************************@posting.google.com >,
Michael Jones wrote:
I am running the same PHP code on two different web site hosts. One
runs this particular snipet of code perfectly, the other gives me
errors.

<?php

// Request the text of all the schools
$query = 'SELECT * FROM members';
$result = mysql_query('SELECT * FROM members');
$num_results=mysql_num_rows($result);
if (!$result)
{
echo "Error performing query: ";
echo mysql_error();
exit();
}
//echo $num_results;
echo("<P> There are ".$num_results." members in our database: </P>");
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo("<P>" . $row[1] ." ". $row[2] . "</P>");
}
?>

Like I said, on one host I get a list of my data, the other I get this
error:

Here are all the customers in our database:

There are ".$num_results." members in our database:

"); for ($i=0; $i < $num_results; $i++) { $row =
mysql_fetch_array($result); echo('
' . $row[1] .' '. $row[2] . '

'); } ?>

Is this because of a setting in my PHP.INI file? Is it not
recognizing the periods between strings?


well, it _should_ recognise the periods as concaternation operators -
this is a fundamental part of the PHP language.

try calling echo without the parentheses - echo is a language
construct, not a function, so they are not necessary.

i don't know why your script is failing on one machine - maybe there
is a bug in the version of PHP installed on that machine?

run phpinfo() on both hosts and see which versions of PHP they are
running.

hc.

Jul 17 '05 #8

P: n/a
Found out from the host that I must end the script in .php in order
for it to work. That seems dumb to me, but there it is...Thanks for
you all of your help.

Herbie Cumberland <no**********@non-existant.tld> wrote in message news:<rp********************************@4ax.com>. ..
In message-id <21**************************@posting.google.com >,
Michael Jones wrote:
I am running the same PHP code on two different web site hosts. One
runs this particular snipet of code perfectly, the other gives me
errors.

<?php

// Request the text of all the schools
$query = 'SELECT * FROM members';
$result = mysql_query('SELECT * FROM members');
$num_results=mysql_num_rows($result);
if (!$result)
{
echo "Error performing query: ";
echo mysql_error();
exit();
}
//echo $num_results;
echo("<P> There are ".$num_results." members in our database: </P>");
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo("<P>" . $row[1] ." ". $row[2] . "</P>");
}
?>

Like I said, on one host I get a list of my data, the other I get this
error:

Here are all the customers in our database:

There are ".$num_results." members in our database:

"); for ($i=0; $i < $num_results; $i++) { $row =
mysql_fetch_array($result); echo('
' . $row[1] .' '. $row[2] . '

'); } ?>

Is this because of a setting in my PHP.INI file? Is it not
recognizing the periods between strings?


well, it _should_ recognise the periods as concaternation operators -
this is a fundamental part of the PHP language.

try calling echo without the parentheses - echo is a language
construct, not a function, so they are not necessary.

i don't know why your script is failing on one machine - maybe there
is a bug in the version of PHP installed on that machine?

run phpinfo() on both hosts and see which versions of PHP they are
running.

hc.

Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.