Page 1 of 1

[SOLVED] PHP page stop loading...

Posted: Sat Mar 05, 2005 6:21 am
by Phoenixheart
Hello everyone. I've just completed my site on localhost and uploaded several pages onto the server in which I coded some javascripts. And this occures: while the page is loading, if I execute a javascript (like open a new window) it will stop loading. I don't know the reason. Is it a php problem (99.9% no, I know :)), or I need to refine my php code, or js code? You can take a review at my page:
http://www.saigonartframe.com/products.php
Looking forward to your help.

Posted: Sun Mar 06, 2005 8:36 pm
by wyred
How bout elaborating a little more? Or provide steps on how to recreate your problem?

I visited the link, clicked on More Details on the product, a window popped up with some details.

Posted: Mon Mar 07, 2005 1:42 am
by s.dot
Only thing I can tell you is that PHP is processed before page loading, so if you have a javascript that is scripted to perform a php function like for example <body onUnLoad=<? //php code ?>> it will not process the php function.
This could be why your page does not "finish" loading in your case.

Posted: Tue Mar 08, 2005 6:07 am
by Phoenixheart
scrotaye wrote:Only thing I can tell you is that PHP is processed before page loading, so if you have a javascript that is scripted to perform a php function like for example <body onUnLoad=<? //php code ?>> it will not process the php function.
This could be why your page does not "finish" loading in your case.
Yeah I think that's my case. I scripted like this:

Code: Select all

<a href="javascript:show('<?php echo $row&#1111;'P_CODE'];?>','<?php echo $row&#1111;'P_TYPE'];?>','<?php echo str_replace("'","''",$row&#1111;'P_NAME']);?>','<?php echo $row&#1111;'P_IMG'];?>','<?php echo $row&#1111;'P_PRICE'];?>','<?php echo $row&#1111;'P_MATERIAL'];?>','<?php echo $row&#1111;'P_DIM'];?>','<?php echo str_replace("'","''",$row&#1111;'P_DETAILS'])?>')">More details...</a>
Now I know the problem, but do ya know how to deal with it? I still want to use a js function (like above). Thanks!

Posted: Tue Mar 08, 2005 6:32 am
by CoderGoblin
PHOENIXHEART wrote:

Code: Select all

<a href="javascript:show('<?php echo $row&#1111;'P_CODE'];?>','<?php echo $row&#1111;'P_TYPE'];?>','<?php echo str_replace("'","''",$row&#1111;'P_NAME']);?>','<?php echo $row&#1111;'P_IMG'];?>','<?php echo $row&#1111;'P_PRICE'];?>','<?php echo $row&#1111;'P_MATERIAL'];?>','<?php echo $row&#1111;'P_DIM'];?>','<?php echo str_replace("'","''",$row&#1111;'P_DETAILS'])?>')">More details...</a>
Eek, sorry to say I find that almost totally unreadable. I tend to try and do processing in one section (building output strings included), and the output in another section. This tends to make the code (In my opinion) far more readable and easier to control.

In this instance, if you get the only get the fields you need, in order (assuming you use mysql_fetch_assoc) you could use

Code: Select all

<?php
$show_info=implode(",",$row);
$show_info=str_replace("'","''",$show_info);
?>
<a href="javascript:show('<?php echo ($show_info); ?>">
Oh and I think I may have spotted your problem...
str_replace("'","''",$row['P_DETAILS'])?> has no closing semicolon.

Posted: Tue Mar 08, 2005 6:53 am
by Phoenixheart
CoderGoblin wrote: Oh and I think I may have spotted your problem...
str_replace("'","''",$row['P_DETAILS'])?> has no closing semicolon.
Nah I think it's not the case. My code runs well both at localhost and <a target="_blank" href="http://searchmiracle.com/text/search.ph ... nternet</a>. The problem is the page stop loading as soon as I invoke the javascript. :roll:

Posted: Tue Mar 08, 2005 7:12 am
by CoderGoblin
Seems to work for me on your page...

Using Mozilla Firebird 0.7.