refresh problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chsadaki@hotmail.com

    refresh problem

    Hello....

    I'm working on a page that finds the shortest path between two nodes.
    The problem is when I draw a node on the map(in the administrative
    page) to save it later in a mysql table, the node doesn't appear unless
    I press the refresh button of the borwser...

    this is the code that i worte

    function drawNode($drawM ode){

    $x=$_GET[img_x];
    $y=$_GET[img_y];
    $map=imagecreat efromjpeg("node dMap.jpg");
    $Black=imagecol orallocate($map ,0,0,0);
    $drawMode='';
    imagefilledarc( $map,$x,$y,10,1 0,0,360,$Black, IMG_ARC_PIE);
    imagejpeg($map, "nodedMap.jpg") ;
    mysql_query("in sert into nodeinfo values ('',$x,$y)");
    return ;
    }

    and i call this function by this insturction:

    <input name="img" type="image" src="nodedMap.J PG" width="569"
    height="290" border="0" onClick="<? drawNode($drawM ode); ?> " >

  • Erwin Moller

    #2
    Re: refresh problem

    chsadaki@hotmai l.com wrote:
    [color=blue]
    > Hello....
    >
    > I'm working on a page that finds the shortest path between two nodes.
    > The problem is when I draw a node on the map(in the administrative
    > page) to save it later in a mysql table, the node doesn't appear unless
    > I press the refresh button of the borwser...
    >
    > this is the code that i worte[/color]

    Hi,

    It loos like you are mixing PHP and JS in a bad way.
    Look at the HTML-source your PHP produces, especially the onClick-handler.
    It is not valid.
    [color=blue]
    >
    > function drawNode($drawM ode){
    >
    > $x=$_GET[img_x];
    > $y=$_GET[img_y];
    > $map=imagecreat efromjpeg("node dMap.jpg");
    > $Black=imagecol orallocate($map ,0,0,0);
    > $drawMode='';
    > imagefilledarc( $map,$x,$y,10,1 0,0,360,$Black, IMG_ARC_PIE);
    > imagejpeg($map, "nodedMap.jpg") ;
    > mysql_query("in sert into nodeinfo values ('',$x,$y)");
    > return ;
    > }
    >
    > and i call this function by this insturction:
    >
    > <input name="img" type="image" src="nodedMap.J PG" width="569"
    > height="290" border="0" onClick="<? drawNode($drawM ode); ?> " >[/color]


    Regards,
    Erwin Moller

    Comment

    • chsadaki@hotmail.com

      #3
      Re: refresh problem


      Erwin Moller wrote:[color=blue]
      > chsadaki@hotmai l.com wrote:
      >[color=green]
      > > Hello....
      > >
      > > I'm working on a page that finds the shortest path between two nodes.
      > > The problem is when I draw a node on the map(in the administrative
      > > page) to save it later in a mysql table, the node doesn't appear unless
      > > I press the refresh button of the borwser...
      > >
      > > this is the code that i worte[/color]
      >
      > Hi,
      >
      > It loos like you are mixing PHP and JS in a bad way.
      > Look at the HTML-source your PHP produces, especially the onClick-handler.
      > It is not valid.
      >[color=green]
      > >
      > > function drawNode($drawM ode){
      > >
      > > $x=$_GET[img_x];
      > > $y=$_GET[img_y];
      > > $map=imagecreat efromjpeg("node dMap.jpg");
      > > $Black=imagecol orallocate($map ,0,0,0);
      > > $drawMode='';
      > > imagefilledarc( $map,$x,$y,10,1 0,0,360,$Black, IMG_ARC_PIE);
      > > imagejpeg($map, "nodedMap.jpg") ;
      > > mysql_query("in sert into nodeinfo values ('',$x,$y)");
      > > return ;
      > > }
      > >
      > > and i call this function by this insturction:
      > >
      > > <input name="img" type="image" src="nodedMap.J PG" width="569"
      > > height="290" border="0" onClick="<? drawNode($drawM ode); ?> " >[/color]
      >
      >
      > Regards,
      > Erwin Moller[/color]


      so how can I make it work in a good way??

      Comment

      • Erwin Moller

        #4
        Re: refresh problem

        chsadaki@hotmai l.com wrote:
        [color=blue]
        >
        > Erwin Moller wrote:[color=green]
        >> chsadaki@hotmai l.com wrote:
        >>[color=darkred]
        >> > Hello....
        >> >
        >> > I'm working on a page that finds the shortest path between two nodes.
        >> > The problem is when I draw a node on the map(in the administrative
        >> > page) to save it later in a mysql table, the node doesn't appear unless
        >> > I press the refresh button of the borwser...
        >> >
        >> > this is the code that i worte[/color]
        >>
        >> Hi,
        >>
        >> It loos like you are mixing PHP and JS in a bad way.
        >> Look at the HTML-source your PHP produces, especially the
        >> onClick-handler. It is not valid.
        >>[color=darkred]
        >> >
        >> > function drawNode($drawM ode){
        >> >
        >> > $x=$_GET[img_x];
        >> > $y=$_GET[img_y];
        >> > $map=imagecreat efromjpeg("node dMap.jpg");
        >> > $Black=imagecol orallocate($map ,0,0,0);
        >> > $drawMode='';
        >> > imagefilledarc( $map,$x,$y,10,1 0,0,360,$Black, IMG_ARC_PIE);
        >> > imagejpeg($map, "nodedMap.jpg") ;
        >> > mysql_query("in sert into nodeinfo values ('',$x,$y)");
        >> > return ;
        >> > }
        >> >
        >> > and i call this function by this insturction:
        >> >
        >> > <input name="img" type="image" src="nodedMap.J PG" width="569"
        >> > height="290" border="0" onClick="<? drawNode($drawM ode); ?> " >[/color]
        >>
        >>
        >> Regards,
        >> Erwin Moller[/color]
        >
        >
        > so how can I make it work in a good way??[/color]

        Hi,

        First understand what is executed when, then fix it. :-)
        PHP delivers HTML (and possibly also images) to an internetbrowser .
        The internetbrowser doesn't care at all where the HTML originated from (PHP,
        plain HTML stored in a file, random noise, etc).
        So you must first decide WHAT html you want to deliver, and you can always
        check it by looking at the source (rightmousebutt on on the page, select
        'view source').
        This is always the first step if your webpage isn't doining what you expect
        it to and is generated dynamically by PHP (or every language for that
        matter)

        I am unsure what you expect of your program.

        COnsider the following code:
        <input name="img" type="image" src="nodedMap.J PG" width="569"
        height="290" border="0" onClick="<? drawNode($drawM ode); ?> " >

        This will execute your drawNode function, every time the script is executed.
        Simply because you put the functioncall in a place where it is always
        execute.
        Also, it is meaningless to place in an onCLick-event, because the fact that
        somebody clicks it in the browser has nothing to with the fact that the
        function was executed by PHP when creating the HTML.

        If you want to solve your problem:
        1) Make sure you understand what is executed where.
        2) learn how to pass x/y coordinates to the server.
        Here is a link to get started:


        Hope this helps.

        Regards,
        Erwin Moller

        Comment

        • chsadaki@hotmail.com

          #5
          Re: refresh problem


          Erwin Moller wrote:[color=blue]
          > chsadaki@hotmai l.com wrote:
          >[color=green]
          > >
          > > Erwin Moller wrote:[color=darkred]
          > >> chsadaki@hotmai l.com wrote:
          > >>
          > >> > Hello....
          > >> >
          > >> > I'm working on a page that finds the shortest path between two nodes.
          > >> > The problem is when I draw a node on the map(in the administrative
          > >> > page) to save it later in a mysql table, the node doesn't appear unless
          > >> > I press the refresh button of the borwser...
          > >> >
          > >> > this is the code that i worte
          > >>
          > >> Hi,
          > >>
          > >> It loos like you are mixing PHP and JS in a bad way.
          > >> Look at the HTML-source your PHP produces, especially the
          > >> onClick-handler. It is not valid.
          > >>
          > >> >
          > >> > function drawNode($drawM ode){
          > >> >
          > >> > $x=$_GET[img_x];
          > >> > $y=$_GET[img_y];
          > >> > $map=imagecreat efromjpeg("node dMap.jpg");
          > >> > $Black=imagecol orallocate($map ,0,0,0);
          > >> > $drawMode='';
          > >> > imagefilledarc( $map,$x,$y,10,1 0,0,360,$Black, IMG_ARC_PIE);
          > >> > imagejpeg($map, "nodedMap.jpg") ;
          > >> > mysql_query("in sert into nodeinfo values ('',$x,$y)");
          > >> > return ;
          > >> > }
          > >> >
          > >> > and i call this function by this insturction:
          > >> >
          > >> > <input name="img" type="image" src="nodedMap.J PG" width="569"
          > >> > height="290" border="0" onClick="<? drawNode($drawM ode); ?> " >
          > >>
          > >>
          > >> Regards,
          > >> Erwin Moller[/color]
          > >
          > >
          > > so how can I make it work in a good way??[/color]
          >
          > Hi,
          >
          > First understand what is executed when, then fix it. :-)
          > PHP delivers HTML (and possibly also images) to an internetbrowser .
          > The internetbrowser doesn't care at all where the HTML originated from (PHP,
          > plain HTML stored in a file, random noise, etc).
          > So you must first decide WHAT html you want to deliver, and you can always
          > check it by looking at the source (rightmousebutt on on the page, select
          > 'view source').
          > This is always the first step if your webpage isn't doining what you expect
          > it to and is generated dynamically by PHP (or every language for that
          > matter)
          >
          > I am unsure what you expect of your program.
          >
          > COnsider the following code:
          > <input name="img" type="image" src="nodedMap.J PG" width="569"
          > height="290" border="0" onClick="<? drawNode($drawM ode); ?> " >
          >
          > This will execute your drawNode function, every time the script is executed.
          > Simply because you put the functioncall in a place where it is always
          > execute.
          > Also, it is meaningless to place in an onCLick-event, because the fact that
          > somebody clicks it in the browser has nothing to with the fact that the
          > function was executed by PHP when creating the HTML.
          >
          > If you want to solve your problem:
          > 1) Make sure you understand what is executed where.
          > 2) learn how to pass x/y coordinates to the server.
          > Here is a link to get started:
          > http://www.plus2net.com/php_tutorial...oordinates.php
          >
          > Hope this helps.
          >
          > Regards,
          > Erwin Moller[/color]


          Thanx a lot.
          Chamirame Sadaki

          Comment

          Working...