Welcome to WebmasterWorld Guest from 54.90.204.233

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Trying to debug PHP

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

New User

5+ Year Member

joined:Feb 14, 2011
posts:17
votes: 0


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>";

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

Senior Member

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

joined:Sept 25, 2005
posts:2046
votes: 340


Have you checked your error log?
5:26 pm on Jan 2, 2017 (gmt 0)

Junior Member

5+ Year Member

joined:Aug 15, 2011
posts:51
votes: 2



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.
8:40 pm on Jan 2, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15450
votes: 739


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.)
10:07 pm on Jan 2, 2017 (gmt 0)

Senior Member

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

joined:Sept 25, 2005
posts:2046
votes: 340


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.)
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members