Hi,
This is basically the same question as Troy's from earlier today...but I can't get it to work even with the suggestions provided.
I'm trying to pass a variable (webpage.php?mopt=1) in, then qualify on the "mopt" value, set a variable ($subj), then use "$subj" in my SELECT. Here's the script...any suggestions on why this won't work would be much appreciated.
Thanks,
Adam.
I believe the query is returning no results, not failing as I can hack up the select to invoke the 'or die("query failed...")', and I can replace $subj in the select with 'philo_bphilo' and get the expected results...all that the script below returns to the browser is the $mopt value and $subj which corresponds per the if/else's.
<?php
if ($mopt == 0)
$subj = "bite me";
else if ($mopt == 1)
$subj = "philo_bphilo";
else if ($mopt == 2)
$subj = "philo_bhist";
else
$subj = "null";
include("../includes/cnnctn.inc.php");
mysql_connect("$hostname", "$db_user", "$password") or die ("Connection to database refused.");
mysql_select_db("$db") or die ("Database missing or inaccessible.");
function get_entry() {
$get_entry = "select id,date,title,text,flag from content1 where subj='$subj' and flag=1";
$entry_result = mysql_query($get_entry) or die ("query failed $get_entry");
$column_count = mysql_num_fields($entry_result);
while ($row = mysql_fetch_row($entry_result)) {
$id = $row[0];
$date = $row[1];
$title = $row[2];
$text = $row[3];
$flag = $row[4];
print("id: $id<br>");
print("flag: $flag<br>");
print("date: $date<br>");
print("<h2>$title</h2><br>");
print("$text<p>");
print("LOOK>>>$mopt<p>");
}
}
?>
<head>
</head>
<DIV ID="workLayer" STYLE="position: absolute; left: 0px; top: 0px; width: 432px; height: 1px; z-index: 1; visibility: visible;">
<?php get_entry("get_entry"); ?>
this line does print $mopt as expected
<br> <?php print("$mopt"); ?>
this line does print $subj as expected
<br> <?php print("$subj"); ?>
</DIV>
</body>
<?php include("../includes/nocache1.inc"); ?>
php 4.0.6
mySQL 3.23.39-nt
win2000pro
apache 1.3.22
ie 5.5