|
|
After upgrading to PHP 4.3.4, no worky?
|
|
|
|
Dedicated MacNNer
Join Date: Jul 2001
Location: Trapped in Amber
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
Senior User
Join Date: Dec 2002
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Jul 2001
Location: Trapped in Amber
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
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...
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Jan 2003
Status:
Offline
|
|
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']
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Dec 2002
Status:
Offline
|
|
Oops, my bad! Didn't even look at the code! Anyway, glad ya got it fixed.
|
Travis Sanderson
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Jul 2001
Location: Trapped in Amber
Status:
Offline
|
|
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 Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|