473,386 Members | 1,609 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,386 software developers and data experts.

PHP.INI Question - Maybe

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
8 1706
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
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
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
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
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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dan V. | last post by:
What do you recommend to use for saving time and get great results for making image and css buttons on a site? Also top tabs like for navigation. Separate question maybe is what is the best tool...
13
by: Andy K | last post by:
Hi , I'm wondering what's going on with a restore I'm trying to do . My DB2 version is a 7.2 on a Linux RH ES 2.1 . I've copy a recent backup that was on NAS for a test on my machine . I...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
25
by: Amarendra GODBOLE | last post by:
Hi, I am working on a legacy user space app, which has been developed entirely in C, some 15 years ago. Needless to say, it does not even partially conform to any standard. My team is in the...
2
by: Efy. | last post by:
Hello all! I wonder if the following subject is a Crystal issue or what? When ever I have a field that includes hebrew(-RTL language) and numbers all the spaces beetwen the words and the numbers...
1
by: frizzle | last post by:
Hi there, I'm building a forum with a mysql backend. The forum has the following structure: - category |--> forum |--> thread |--> replies Once the user has defined a forum (id), i first...
9
by: James Crosswell | last post by:
I'm not sure if I'm going about this the right way - it may be that Generics might be able to help me out here... but here goes: I have three classes as follows class BaseEdit class WidgetEdit:...
8
by: shuisheng | last post by:
Dear All, I have a libaray which provides a base class of name Base and several derived classes of name Derived1, Derived2 and so on. I want to add a client data into those classes, such as ...
37
by: HangEveryRepubliKKKan | last post by:
"Jeremy Fisher" <freya@linux.serverwrote So much for LinTard Land. Here in the real world.... Microsoft profits up 23% this year over last. Ahahahahahahaha.... Vista is now eating away at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.