470,612 Members | 2,437 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,612 developers. It's quick & easy.

php scripts no longer working after upgrade

i recently upgraded from fedora core 5 to cent os 4.4 with php 4.3
mysql 4.1 and apache 2.0.52, and all of the php scripts i had which
called specific entries from mysql are no longer working

if i had a link display_story.php?id=334 it would know do display the
entry which matched id 334, my code to display the entry looks like
this

<?php
$Host="localhost";
$User="user";
$Password="password";
$DBName="database";

$Link=mysql_connect($Host, $User, $Password);
$Query="SELECT * from table WHERE sid=$id;
$Result=mysql_db_query($DBName,$Query, $Link);
while($Row=mysql_fetch_array($Result)){
print("<table width=\"500\">\n");
print("<tr>\n");
print("<td valign=\"bottom\">\n");
print("<p class=\"page_title\">$Row[title]\n");
print("<p>\n");
print("<i>$Row[hometext]</i>\n");
print("</td>\n");
print("<td>\n");
$Topimage=$Row[topic];
include 'top_image.php';
print("</td>\n");
print("</tr>\n");
print("</table>\n");
print("<p>\n");
print("$Row[bodytext]\n");
print("<div align=right><a href=\"javascript: history.go(-1)\">Back</
a></div></td>\n");
}
mysql_close($Link);
?>

the error message in my logs tell me that $Query="SELECT * from table
WHERE sid=$id; is the problem

[client 204.50.205.242] PHP Notice: Undefined variable: id in
**********
[client 204.50.205.242] PHP Warning: mysql_fetch_array(): supplied
argument is not a valid mysql result resource in
*************************** on line 10

i have tried turning on register_globals but the problem persists

any ideas on how i can fix this in php.ini without having to go and re-
write all of my scripts (i'm kind of lazy today)

thanks

Apr 2 '07 #1
11 1742
cw****@theatomicmoose.ca wrote:
i recently upgraded from fedora core 5 to cent os 4.4 with php 4.3
mysql 4.1 and apache 2.0.52, and all of the php scripts i had which
called specific entries from mysql are no longer working

if i had a link display_story.php?id=334 it would know do display the
entry which matched id 334, my code to display the entry looks like
this

<?php
$Host="localhost";
$User="user";
$Password="password";
$DBName="database";

$Link=mysql_connect($Host, $User, $Password);
$Query="SELECT * from table WHERE sid=$id;
$Result=mysql_db_query($DBName,$Query, $Link);
while($Row=mysql_fetch_array($Result)){
print("<table width=\"500\">\n");
print("<tr>\n");
print("<td valign=\"bottom\">\n");
print("<p class=\"page_title\">$Row[title]\n");
print("<p>\n");
print("<i>$Row[hometext]</i>\n");
print("</td>\n");
print("<td>\n");
$Topimage=$Row[topic];
include 'top_image.php';
print("</td>\n");
print("</tr>\n");
print("</table>\n");
print("<p>\n");
print("$Row[bodytext]\n");
print("<div align=right><a href=\"javascript: history.go(-1)\">Back</
a></div></td>\n");
}
mysql_close($Link);
?>

the error message in my logs tell me that $Query="SELECT * from table
WHERE sid=$id; is the problem

[client 204.50.205.242] PHP Notice: Undefined variable: id in
**********
[client 204.50.205.242] PHP Warning: mysql_fetch_array(): supplied
argument is not a valid mysql result resource in
*************************** on line 10

i have tried turning on register_globals but the problem persists

any ideas on how i can fix this in php.ini without having to go and re-
write all of my scripts (i'm kind of lazy today)

thanks
Hi,

Did you print out the POST and GET array?
Above your script:
echo "POST contains:<pre>";
print_r($_POST);
echo "</pre>";
echo "GET contains:<pre>";
print_r($_GET);
echo "</pre>";

If of them contain the id, then your script relies on registering globals.
If so, better fix that and get your data in the right way, with $_GET[] and
$_POST[] supergloabls.

If this is the case, I do NOT understand why enabling register_globals in
php.ini didn't fix it. Did you restart your IIS, or signal apache after
making changes into php.ini??

Regards,
Erwin Moller

Apr 3 '07 #2
cw****@theatomicmoose.ca wrote:
[snip]
>
i have tried turning on register_globals but the problem persists

any ideas on how i can fix this in php.ini without having to go and re-
write all of my scripts (i'm kind of lazy today)

thanks
Try popping a phpinfo() into the top of your script and checking
register_globals really is On, if not then something is not right in
configuration or its overridden somewhere (maybe a .htaccess)

OR

Do it properly and $id=$_GET["id"]; at the top of script

OR

Make your own function to create the vars and put this into an include
file to be included at top of your page, but a bit risky security
wise, something like (I write this straight into email so not tested):

autoreg.php

<?php
foreach($_GET AS $key=>$value) {
$$key=$value;
}
?>

test.php
<?php
require_once('autoreg.php');
if (isset($id)) echo "{$id}<br />";
if (isset($name)) echo "{$name}<br />";
?>

If you called this as myreg.php?id=1&name=Bob then it would print both
the $id value and $bob value, you'd need to amend autoreg.php to include
$_POST, $_SESSION etc. if you wanted and in the order you wanted as one
would override the other if the key existed in say $_GET and $_SESSION etc.

Personally, I'd write your code correctly for the newer PHP 5 standard
if you can ;-)
Apr 4 '07 #3
If you called this as myreg.php?id=1&name=Bob then it would print both
the $id value and $bob value, you'd need to amend autoreg.php to include
$_POST, $_SESSION etc. if you wanted and in the order you wanted as one
would override the other if the key existed in say $_GET and $_SESSION etc.
I meant test.php?id=1&name=Bob obviously. Oops.
Apr 4 '07 #4
off topic (or generally on topic throughout all groups):

Your client isn't properly configured. Please enter a real mail address to
enable people to contact you. If you are afraid of spam, you have the
possibility of creating an extra mail account just for your newsgroup
stuff. Also please give us your realname, so we know who we're talking to.

Thanks in advance.
Apr 4 '07 #5
Simon Stienen wrote:
off topic (or generally on topic throughout all groups):

Your client isn't properly configured. Please enter a real mail address to
enable people to contact you. If you are afraid of spam, you have the
possibility of creating an extra mail account just for your newsgroup
stuff. Also please give us your realname, so we know who we're talking to.

Thanks in advance.
Why?
Who cares what the real email of cwhite@atomicmoose... is?
If you have a response for him/her, you write it here like you did.

I know I won't publish my real emails here.

Regards,
Erwin Moller
Apr 4 '07 #6
Simon Stienen wrote:
off topic (or generally on topic throughout all groups):

Your client isn't properly configured. Please enter a real mail address to
enable people to contact you. If you are afraid of spam, you have the
possibility of creating an extra mail account just for your newsgroup
stuff. Also please give us your realname, so we know who we're talking to.

Thanks in advance.
I'm with Erwin. Although I have a munged email address here, I don't
check it often. Ask in a newsgroup, expect a response in a newsgroup.

If people want to contact me by email, fine. My normal hourly rates
apply, payable in advance.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 4 '07 #7
On 2007-04-04 04-52-22, Erwin Moller wrote:
I know I won't publish my real emails here.
Instead, you're redirecting more spam to spamyourself.com since 2003. :P
Under this aspect, us**@example.com is better, since it's pointing to a
domain which is reserved by the DNS RFC. (Which I guess is not to his
credit, but to the one of the Thunderbird developers.)

Then again, you're at least giving us your name.

However - as every better Usenet netiquette should state - private answers
to the poster should not be posted as f'ups but as direct reply to the
poster. If there is no mail given, this is (obviously) not possible. If
someone doesn't want to be communicated with, he shouldn't post to NGs from
the beginning.

So *if* you're posting, you should make yourself contactable.

Besides: us**@example.com might just be new to this and need a shove into
the correct direction.
Apr 4 '07 #8
On 2007-04-04 05-16-18, Simon Stienen wrote:
So *if* you're posting, you should make yourself contactable.
Besides: If *you* were contactable by mail, we wouldn't need to have this
off topic discussion here. :]
Apr 4 '07 #9
X-noarchive: yes
Simon Stienen wrote:
off topic (or generally on topic throughout all groups):

Your client isn't properly configured. Please enter a real mail address to
enable people to contact you. If you are afraid of spam, you have the
possibility of creating an extra mail account just for your newsgroup
stuff. Also please give us your realname, so we know who we're talking to.

Thanks in advance.
I'm also with Erwin, and Jerry. For several reasons I don't even use my
real name here (none of them related to what I post on usenet). If that
is a problem, feel free to PLOINK me. I never (uhh, well once, right
Erwin, Jerry?) abused that relative anonimity on usenet, all my postings
are meant sincere, and mostly if not all on topic.

Personally I don't care a lot what name people post under. And I tried
using a real email address once, and still get a gazillion spam messages
a day related to that faux-pas.

My IP address has always been the same, and I don't mind. So with a
little handiwork you probably can find my real identity. Feel free.

You may even find my ip has once been abused by someone (I know his real
name and addy now), for a hate-posting addressed at himself hoping to be
able to pin it on me. My ISP, the police and myself still can only guess
how the perp managed to use their servers and my ip without having
access (to my knowledge) to my home or adsl line. He keeps denying btw.

If you ever feel the need to email me, just tell me and I'll gladly send
you a valid address.

Sh.
Apr 4 '07 #10
Simon Stienen wrote:
On 2007-04-04 04-52-22, Erwin Moller wrote:
>I know I won't publish my real emails here.

Instead, you're redirecting more spam to spamyourself.com since 2003. :P
Under this aspect, us**@example.com is better, since it's pointing to a
domain which is reserved by the DNS RFC. (Which I guess is not to his
credit, but to the one of the Thunderbird developers.)
Quite true.
Then again, you're at least giving us your name.

However - as every better Usenet netiquette should state - private answers
to the poster should not be posted as f'ups but as direct reply to the
poster. If there is no mail given, this is (obviously) not possible. If
someone doesn't want to be communicated with, he shouldn't post to NGs from
the beginning.
Netiquette says posts in a newsgroup should be answered in a newsgroup.
There is nothing which indicates you need to share your email address.

I do because I choose to. But even munged like it is, it still gets a
lot of spam. I don't check it often as it's only used for usenet stuff.

But I also know a lot of people in various newsgroups who don't share
their email addresses. No one else seems to have a problem with that.
And if you don't want to respond in a newsgroup, that's fine. But don't
criticize someone else for not having a valid email address.
So *if* you're posting, you should make yourself contactable.
So *if* you're responding, you should do it in the newsgroup.
Besides: us**@example.com might just be new to this and need a shove into
the correct direction.
Yes, he may be new. And it looks like he's doing perfectly fine like he is.

Besides - he wasn't the one with the problem. He was responding to
cwhite, who is the one with the problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 4 '07 #11
Schraalhans Keukenmeester wrote:
If you ever feel the need to email me, just tell me and I'll gladly send
you a valid address.

Sh.
Hi there!

Agreed, for reason of Netiquette I will repost here with a name just so
you know who is posting in future ;-)

I will keep us**@example.com however as it is reserved for use in
development and will guard me from spam, no need for a real address,
just causes lots of unwanted spam traffic.
Apr 4 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by STEPHEN GOODE | last post: by
8 posts views Thread by Jan Danielsson | last post: by
1 post views Thread by Kaloyan Iliev Iliev | last post: by
8 posts views Thread by Leszek | last post: by
6 posts views Thread by Demetri | last post: by
5 posts views Thread by stefaan.himpe | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.