+ Reply to Thread
Results 1 to 6 of 6

Thread: need php/mysql help

  1. #1
    sarroya is offline x10Hosting Member sarroya is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    3

    need php/mysql help

    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

  2. #2
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: need php/mysql help

    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?

  3. #3
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: need php/mysql help

    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 by descalzo; 08-12-2009 at 10:47 AM.
    Nothing is always absolutely so.

  4. #4
    sarroya is offline x10Hosting Member sarroya is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    3

    Re: need php/mysql help

    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 by sarroya; 08-13-2009 at 05:12 AM. Reason: Automerged Doublepost

  5. #5
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: need php/mysql help

    Did you try the other things I mentioned to narrow down to possibilities?

  6. #6
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: need php/mysql help

    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.
    Nothing is always absolutely so.

+ Reply to Thread

Similar Threads

  1. Need PHP/mySQL Coders
    By kesne in forum Ads & Offers
    Replies: 0
    Last Post: 12-16-2008, 02:27 PM
  2. Any good PHP/MySQL tutorials out there?
    By shiveringtim in forum Off Topic
    Replies: 4
    Last Post: 05-13-2008, 10:34 PM
  3. PHP/mySQL noob question
    By alexxz4 in forum Programming Help
    Replies: 10
    Last Post: 04-05-2008, 01:56 PM
  4. I'll do HTML, PHP/MySQL work for credits
    By lupus_42 in forum Earning Money
    Replies: 9
    Last Post: 02-23-2008, 04:36 PM
  5. PHP/MySQL help!
    By Zenax in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 08-15-2006, 06:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers