Hello all,
This is my first post here, i have come to php from the world of python. Things seem more stable there.
I am having a bizarre problem with Include, which is a simple enough statement and is straightforward in python. It should just include the code in the file. I call it as such:
include("include/arjunaClassLib.php")
arjunaClassLib.php just has a regular class (Shown at the botton of this post for reference)
However instead of including the code when i see this in the browser, the code appears on my browser. Ie instead of running it, it is showing it. Yes it is not a tag issue, because, and check this out, if i copy and paste the code into my file instead of including it, it works beautifully.
Why could this be?
arjunaClassLib.php
php?
class ajSelectBox {
function conDb ($dbName,$sql)
{
$con = mysql_connect("localhost","root","karunaworks");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbName, $con);
$result= mysql_query($sql);
mysql_close($con);
return $result;
}
function makeSelectBox($selName, $selValue, $selText, $onchangeWhat, $srcTable)
{
#Get the data for the select box from the database
$sql="SELECT " . $selValue ." , " . $selText . " from " . $srcTable;
$result=conDb("nbc", $sql);
# Construct the select box
$a="<select id=".$selName . " name=".$selName . " onchange='" . $onchangeWhat . "(this.value)'>";
$a=$a . " <option value=''>Select a " .$selText . "</option>";
while($row = mysql_fetch_array($result))
{
$a=$a. "<option value=" . $row[$selValue] . ">" . $row[$selText]."</option>";
}
$a=$a ."</select>";
return $a;
}
}