Forum Moderators: coopster

Message Too Old, No Replies

Trying to debug PHP

         

complete

4:31 pm on Jan 2, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



In these few php lines, the first and the last lines are executed without any problem, but the middle two lines are ignored as if they are not even there.  Any suggestions?


echo "<script type='text/javascript'>alert('Web Site Under Test -- line 440');</script>";

$tempstr = addslashes($where_sql);
echo "<script type='text/javascript'>alert('$where_sql -- '".$where_sql."');</script>";

echo "<script type='text/javascript'>alert('Web Site Under Test -- line 445');</script>";

robzilla

5:06 pm on Jan 2, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have you checked your error log?

nettulf

5:26 pm on Jan 2, 2017 (gmt 0)

10+ Year Member




It produces javascript with error.

Remove the single quote in the middle, between the two $where_sql - there should be only a double quote there.

lucy24

8:40 pm on Jan 2, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can I assume that the very first thing you tried was reducing the middle section to
echo $where_sql
to see what happens? That is: If the code says "do stuff to this variable and display the result", start by displaying the variable in its before-doing-stuff form.

the middle two lines are ignored as if they are not even there

Huh. That's not the way I expect php--or even javascript--to behave. Are the script lines visible in the HTML? If so, the php did what it's supposed to; it's the javascript that has a problem. (After trying it three different ways, I see that nettulf is right: you end up with a superfluous ' in the javascript, yielding an odd number of ' in the alert argument.)

robzilla

10:07 pm on Jan 2, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



between the two $where_sql - there should be only a double quote there.

Well-spotted :-)

(You could also escape those single quotes with a backslash.)