Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > After upgrading to PHP 4.3.4, no worky?

After upgrading to PHP 4.3.4, no worky?
Thread Tools
velocipede
Dedicated MacNNer
Join Date: Jul 2001
Location: Trapped in Amber
Status: Offline
Reply With Quote
Nov 16, 2003, 11:54 AM
 
Arrgh! Another newb PHP question!!! I had the script below running just fine, but after upgrading to PHP 4.3.4, it's no good. It's like the $id variable is not being passed to the script. Before, typing in http://page.php?id=1 would give me the corresponding image in the database, but now the browser downloads the page, excluding everything in the if statement, leading me to believe it's not getting the $id value. I know the register_globals value is off now, when it was on before, but would this be the cause, and if so, how do I work around it? I've tried using $id = $_POST['id']; on a hunch, but still nothing...
Ack, help!


<code> if($id) {
// you may have to modify login information for your database server:
@MYSQL_CONNECT("localhost","root","");

@mysql_select_db("test");
$query = "select photo, filetype, from photo_store where id=$id";
$result = @MYSQL_QUERY($query);
$type = @MYSQL_RESULT($result,0,"filetype");
$data = @MYSQL_RESULT($result,0,"photo");
@MYSQL_RESULT($result,0,"caption");
Header("Content-type: $type");
echo $data;
};
</code>

edited to change user to id
( Last edited by velocipede; Nov 16, 2003 at 04:19 PM. )
I wanna see movies of my dreams.
     
redJag
Senior User
Join Date: Dec 2002
Status: Offline
Reply With Quote
Nov 16, 2003, 01:34 PM
 
Originally posted by velocipede:
so, how do I work around it? I've tried using $id = $_POST['user'];
Try using $id = $_GET['user']; (or is it just user..) on a more different hunch!

edit:
$id = $_GET['user']; and $id = $_GET[user]; both work
Travis Sanderson
     
velocipede  (op)
Dedicated MacNNer
Join Date: Jul 2001
Location: Trapped in Amber
Status: Offline
Reply With Quote
Nov 16, 2003, 05:37 PM
 
Originally posted by redJag:
Try using $id = $_GET['user']; (or is it just user..) on a more different hunch!

edit:
$id = $_GET['user']; and $id = $_GET[user]; both work
Tried that, still not working...Ack!
I wanna see movies of my dreams.
     
Simon Mundy
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Nov 16, 2003, 05:59 PM
 
Originally posted by velocipede:
Tried that, still not working...Ack!
It wouldn't work - you're checking the value of 'user', not 'id'!

Try $id = $_GET['id'] or $id = $_REQUEST['id']

If you're super-paranoid about what's passed directly to your SQL statements, it's even safer to use:

$id = (INT) $_GET['id']
Computer thez nohhh...
     
schk
Dedicated MacNNer
Join Date: Jan 2003
Status: Offline
Reply With Quote
Nov 16, 2003, 05:59 PM
 
replace $id with $_GET['id']

With register globals off you must reference variables passed through a URL via $_GET['variablename'] and any variables passed through forms via method=post as $_POST['variablename']
     
redJag
Senior User
Join Date: Dec 2002
Status: Offline
Reply With Quote
Nov 16, 2003, 06:54 PM
 
Oops, my bad! Didn't even look at the code! Anyway, glad ya got it fixed.
Travis Sanderson
     
velocipede  (op)
Dedicated MacNNer
Join Date: Jul 2001
Location: Trapped in Amber
Status: Offline
Reply With Quote
Nov 16, 2003, 07:44 PM
 
Originally posted by schk:
replace $id with $_GET['id']

With register globals off you must reference variables passed through a URL via $_GET['variablename'] and any variables passed through forms via method=post as $_POST['variablename']
Ahh, that was it! Much thanks!
Just to clarify, too...I actually edited my post from user=$id to id=$id, but after red.Jag responded, hence a little confusion. Anyways, thanks to all who posted, another desk's imprints on my forehead, another lesson learned.
I wanna see movies of my dreams.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:18 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,