Jump to content

[SOLVED] Quick Syntax Question


fmpros

Recommended Posts

Hi folks,

 

I'm getting the following error: "unexpected T_LNUMBER".  I'm trying to build a dynamic table in PHP it was working great until I attempted to include a java reference in one of my links. A watered down version of the code is as follows:

 

$apps_html = '<table>';
$apps_html.= '<tr class="tableHeader">';
$apps_html.= '<th scope="col">VIEW</th>';
$apps_html.= '<th scope="col">TITLE</th>';
$apps_html.= '<th scope="col">DATE MODIFIED</th>';
$apps_html.= '<th scope="col">STATUS</th>';
$apps_html.= '<th scope="col">EDIT</th>';
$apps_html.= '<th scope="col">DELETE</th>';
$apps_html.= '</tr>';
$apps_html.= '<tr class="tablerow2">';
$apps_html.= '<td><a href="link.php">view</a></td>';
$apps_html.= '<td>' . $var1 . '</td>';
$apps_html.= '<td>' . $var2 . '</td>';
$apps_html.= '<td>' . $var3 . '</td>';
if($var1 == 'PENDING'){
	$apps_html.= '<td><a href="delete.php">delete</a></td>';
}else{
	$apps_html.= '<td><a href="window.html" onclick="popUp(this.href,'200','400'); return false;"></a></td>';
}
$apps_html.= '</tr>';
$apps_html.= '</table>';

 

The document body looks something like this:

<html>
<head>
<title>I hate java</title>
</head>
<body>
<?php echo $apps_html; ?>
</body>
</html>

 

 

The problem is with this line obviously:

$apps_html.= '<td><a href="window.html" onclick="popUp(this.href,'200','400'); return false;"></a></td>'; 

 

Can anyone help me with the correct syntax to include java variables in my href?  Thanks for your time!

 

-John

Link to comment
https://forums.phpfreaks.com/topic/177720-solved-quick-syntax-question/
Share on other sites

$apps_html.= '<td><a href="window.html" onclick="popUp(this.href,'200','400');

 

 

Should be:

 

 

$apps_html.= '<td><a href="window.html" onclick="popUp(this.href,\'200\',\'400\');';

 

 

When ever you use ' inside of ' you have to put \' if that makes sense.

$apps_html.= '<td><a href="window.html" onclick="popUp(this.href,'200','400'); return false;"></a></td>';

 

should be

 

$apps_html.= '<td><a href="window.html" onclick="popUp(this.href,\'200\',\'400\'); return false;"></a></td>';

 

Have to escape the single quotes or they tell PHP to end the string.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.