OK. PHP gets me again.
I had a javascript program that used to work just fine. Then my ISP tightened up the security on PHP, turning "register globals" off among other things and now my Javascript went "North" and I can't figure out how to get it working again.
The problem is the "id" variable isn't being passed to the Javascript function from the anchor tag.
The program is a simple list of upcoming events on a client's page. When the page loads, we run a PHP routine that queries the database and lists the event title and the date. The user clicks on the event title and a popup window comes up with details about the event.
Here's the Javascript function:
<script type="text/javascript" language="JavaScript1.2">
<!--
function _onclick(id)
{
window.open('event.php?id='.concat(id),'Panel','location=no,toolbar=no,width=300,height=200');
return;
}
-->
</script>
Here's the code that passes the info.
<?php
$mysql_table = "event";
$sql_statement = "SELECT title,DbID,DATE_FORMAT(dt,\"%W, %b %e\") FROM ".$mysql_table." order by dt ";
$db = mysql_select_db("my_databasename", $link_id);
$result = mysql_query($sql_statement) or die(mysql_error());
if (mysql_num_rows($result) > 0){
while ($row = mysql_fetch_array($result)) {
?>
<strong><?php echo $row[2]?></strong><br>
<a href="javascript:_onclick(<?php echo $row[1]; ?>)" class="event"><?php echo $row[0]; ?></a><br>
<?php
}
}
?>
The error message we get in the popup window is:
" Error in query: SELECT event, title, DAYNAME(dt), MONTHNAME(dt), DAYOFMONTH(dt) FROM event where Dbid= "
which comes from "event.php", the script called by the Javascript function.
You can view the failed code at:
http://www.ci.conover.nc.us
Thanks for any help you can give this frustrated PHP user.
Cheers!
Kinney