need php/mysql help

sarroya

New Member
Messages
3
Reaction score
0
Points
0
I'm trying to draw points that firstly defined between two values at data.php using post method

#data.php
<?php
:
:
?>
<img src="image.php">
<form action="data.php" method="post"> Between <INPUT type="TEXT" name="from"> And <INPUT type="TEXT" name="to">
<td colspan=5 <input type="submit" name="submit" value="Select"></td> </form>
<?php
if(isset($_POST['submit']))
{

$Fro = $_POST['from']; $Too = $_POST['to'];
:
:
}
?>

At image.php these points are supose to be dawed by taking their coordinates (x,y) from a table under condition that its betwwen the values of $Fro and $Too.

#image.php
<?php
mysql_connect("localhost", "root", "1234") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

$Fro = $_POST['from']; $Too = $_POST['to'];

$check3 = mysql_query("SELECT * FROM data WHERE data.ID BETWEEN '$Fro' AND '$Too' ")or die(mysql_error());
while($info3 = mysql_fetch_array( $check3 ))
{
$time = $info3['ID']; $arrX[$i] = $info3['x']; $arrY[$i] = $info3['y'];
$i += 1; $count = $i;
}
:
:
//a function to draw the points
?>

The problem is that the post contents of $Fro and $Too does't not posted so that it can't be used at image.php (does't have value when posted).
I tried to cookies but does't work also.
any help.
thanks in advance
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
Strange... :S

Firstly, to de-bug, try removing the form action in #data.php so that it posts to the same page and echo $Fro and $Too to see if the post/ variable allocation is working at all.

If that's working try echoing the same immediately after the variable definition in #image.php.

Or have you already tried that..

If cookies don't work, how about passing the $Too and $Fro variables through the URL and obtaining via $_GET?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
My assumption:
I call data.php in the first place, it just displays the form ( since $_POST['submit']) is false ).
I fill in the info and submit it to ... data.php
data.php displays the form and then inserts an image tag like
Code:
<img src="image.php" >
and then image.php creates a png or some other graphic?

IF that is the case, you have to use a GET for the image and adjust the image tag to something like:

Code:
<img src="image.php?from=23&to=44" >

if $Fro is 23 and $Too is 44 in data.php

And then you use $_GET[] in image.php instead of $_POST[] to retrieve the values.

Next time, show where image.php is actually used so we can have some idea of what is actually going on.
 
Last edited:

sarroya

New Member
Messages
3
Reaction score
0
Points
0
this is the full code of image.php

Code:
//image.php
<?php
mysql_connect("localhost", "root", "1234") or die(mysql_error()); 
mysql_select_db("test") or die(mysql_error());
 
$Fro = $_POST['from']; $Too = $_POST['to']; 
 
$check3 = mysql_query("SELECT * FROM data WHERE data.ID BETWEEN '$Fro' AND '$Too' ")or die(mysql_error());
while($info3 = mysql_fetch_array( $check3 )) 
{
$time = $info3['ID']; $arrX[$i] = $info3['x']; $arrY[$i] = $info3['y'];
$i += 1; $count = $i; 
} 
 
$im = @imagecreate(700, 400)
$red = imagecolorallocate ($im, 0xff, 0x00, 0x00);
$stamp = imagecreatefrompng("coolblue_small.png");
 
for ($i = 0; $i< $count; $i += 1){
imagecopy($im, $stamp, imagesx($im) - imagesx($stamp) - $arrX[$i], imagesy($im) - imagesy($stamp) - $arry[$i], 0, 0, imagesx($stamp), imagesy($stamp));
}
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
 
?>
Edit:
this is the full code of image.php

Code:
//image.php
<?php
mysql_connect("localhost", "root", "1234") or die(mysql_error()); 
mysql_select_db("test") or die(mysql_error());
 
$Fro = $_POST['from']; $Too = $_POST['to']; 
 
$check3 = mysql_query("SELECT * FROM data WHERE data.ID BETWEEN '$Fro' AND '$Too' ")or die(mysql_error());
while($info3 = mysql_fetch_array( $check3 )) 
{
$time = $info3['ID']; $arrX[$i] = $info3['x']; $arrY[$i] = $info3['y'];
$i += 1; $count = $i; 
} 
 
$im = @imagecreate(700, 400)
$red = imagecolorallocate ($im, 0xff, 0x00, 0x00);
$stamp = imagecreatefrompng("coolblue_small.png");
 
for ($i = 0; $i< $count; $i += 1){
imagecopy($im, $stamp, imagesx($im) - imagesx($stamp) - $arrX[$i], imagesy($im) - imagesy($stamp) - $arry[$i], 0, 0, imagesx($stamp), imagesy($stamp));
}
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
 
?>

I'v tried $_GET[] and it does't work too.

Code:
//data.php
<img src="image.php">
<form action="data.php" method="get"> Between <INPUT type="TEXT" name="from"> And <INPUT type="TEXT" name="to"> 
<td colspan=5 <input type="submit" name="submit" value="Select"></td> </form>

and changed the image.php and use
Code:
$Fro = $_GET["from"];  $Too = $_GET["to"];
instead of
$Fro = $_POST['from']; $Too = $_POST['to'];
 
Last edited:

freecrm

New Member
Messages
629
Reaction score
0
Points
0
Did you try the other things I mentioned to narrow down to possibilities?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Try calling image.php on its own by just typing into the address bar:

yoursite/path/to/image.php?from=23&to=44

That should help show warnings and other problems.

And I see one quick problem...

Code:
$im = @imagecreate(700, 400)

missing a ';' , also why are you supressing warnings here?

Also, there should be nothing, not even spaces, outside of the <?php ?> tags.

Code:
//image.php

will cause mess up the image.
 
Top