Click to See Complete Forum and Search --> : predefined php variables not working


jamie85
12-19-2005, 05:43 PM
<?
echo "X=$foo_x, Y=$foo_y ";
?>

<form action='' method=post>
<input type="image" alt=' Finding coordinates of an image' src="xy-coordinates.jpg" name="foo" style=cursor:crosshair;/>
</form>



The above code should return the image coordinates when the user clicks on the image.

However when i try on my apache server on my computer, it returns the errors


Notice: Undefined variable: foo_x in Z:\web\httpdocs\coursework 2\coor.php on line 2

Notice: Undefined variable: foo_y in Z:\web\httpdocs\coursework 2\coor.php on line 2


Something not set in my php.ini file maybe??

Thanks

Pinkmischief
12-20-2005, 06:19 AM
Hi im quite new to php (about 3 weeks to be precise lol) but have you set the variables before asking for them so example

<?php $x = "foo_x";
$y = "foo_y";
//then echo x and using
echo ".$x.",".$y."
?>

Im not 100% sure if that code is right but its some of the basic things i been practicing no offence intended.Hope this helps

Regards Pinky

MarkR
12-20-2005, 07:11 AM
You are assuming that register_globals is enabled.

It should not be. Therefore you should use either $_POST['foo_x'] instead of just $foo_x

Mark

jamie85
12-20-2005, 08:06 AM
You are assuming that register_globals is enabled.

It should not be. Therefore you should use either $_POST['foo_x'] instead of just $foo_x

Mark


Nice one. I even changed register_globals to 'On' and it didnt seem to work.

I completely over looked $_POST.

Thanks :D