By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

refresh problem

P: n/a
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($drawMode){

$x=$_GET[img_x];
$y=$_GET[img_y];
$map=imagecreatefromjpeg("nodedMap.jpg");
$Black=imagecolorallocate($map,0,0,0);
$drawMode='';
imagefilledarc($map,$x,$y,10,10,0,360,$Black,IMG_A RC_PIE);
imagejpeg($map,"nodedMap.jpg");
mysql_query("insert into nodeinfo values ('',$x,$y)");
return ;
}

and i call this function by this insturction:

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

Jun 22 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ch******@hotmail.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($drawMode){

$x=$_GET[img_x];
$y=$_GET[img_y];
$map=imagecreatefromjpeg("nodedMap.jpg");
$Black=imagecolorallocate($map,0,0,0);
$drawMode='';
imagefilledarc($map,$x,$y,10,10,0,360,$Black,IMG_A RC_PIE);
imagejpeg($map,"nodedMap.jpg");
mysql_query("insert into nodeinfo values ('',$x,$y)");
return ;
}

and i call this function by this insturction:

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

Regards,
Erwin Moller
Jun 22 '06 #2

P: n/a

Erwin Moller wrote:
ch******@hotmail.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($drawMode){

$x=$_GET[img_x];
$y=$_GET[img_y];
$map=imagecreatefromjpeg("nodedMap.jpg");
$Black=imagecolorallocate($map,0,0,0);
$drawMode='';
imagefilledarc($map,$x,$y,10,10,0,360,$Black,IMG_A RC_PIE);
imagejpeg($map,"nodedMap.jpg");
mysql_query("insert into nodeinfo values ('',$x,$y)");
return ;
}

and i call this function by this insturction:

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

Regards,
Erwin Moller

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

Jun 22 '06 #3

P: n/a
ch******@hotmail.com wrote:

Erwin Moller wrote:
ch******@hotmail.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($drawMode){
>
> $x=$_GET[img_x];
> $y=$_GET[img_y];
> $map=imagecreatefromjpeg("nodedMap.jpg");
> $Black=imagecolorallocate($map,0,0,0);
> $drawMode='';
> imagefilledarc($map,$x,$y,10,10,0,360,$Black,IMG_A RC_PIE);
> imagejpeg($map,"nodedMap.jpg");
> mysql_query("insert into nodeinfo values ('',$x,$y)");
> return ;
> }
>
> and i call this function by this insturction:
>
> <input name="img" type="image" src="nodedMap.JPG" width="569"
> height="290" border="0" onClick="<? drawNode($drawMode); ?> " >

Regards,
Erwin Moller

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


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 (rightmousebutton 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.JPG" width="569"
height="290" border="0" onClick="<? drawNode($drawMode); ?> " >

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
Jun 22 '06 #4

P: n/a

Erwin Moller wrote:
ch******@hotmail.com wrote:

Erwin Moller wrote:
ch******@hotmail.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($drawMode){
>
> $x=$_GET[img_x];
> $y=$_GET[img_y];
> $map=imagecreatefromjpeg("nodedMap.jpg");
> $Black=imagecolorallocate($map,0,0,0);
> $drawMode='';
> imagefilledarc($map,$x,$y,10,10,0,360,$Black,IMG_A RC_PIE);
> imagejpeg($map,"nodedMap.jpg");
> mysql_query("insert into nodeinfo values ('',$x,$y)");
> return ;
> }
>
> and i call this function by this insturction:
>
> <input name="img" type="image" src="nodedMap.JPG" width="569"
> height="290" border="0" onClick="<? drawNode($drawMode); ?> " >
Regards,
Erwin Moller

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


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 (rightmousebutton 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.JPG" width="569"
height="290" border="0" onClick="<? drawNode($drawMode); ?> " >

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

Thanx a lot.
Chamirame Sadaki

Jun 23 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.