So probably not the right forum, but couldn’t think where this should go.
Here’s my script:
[code=php]
<?php
class jsVar{
var $varName;
var $varValue;
var $error;
function jsVar($myarray){
if(count($myarray) == 2 && !is_null($myarray[‘varname’]) && !is_null($myarray[‘varvalue’])){
//only do this for proper arrays
$this->varName=$myarray[‘varname’];
$this->varValue=$myarray[‘varvalue’];
}//if
else{
$this->error=”Invalid column count or array keys found.”;
}
}
function errorCheck(){
return isset($this->error);
}
function showVals(){
if(!$this->errorCheck()){
echo “var “.$this->varName.” = “”.nl2br(stripslashes($this->varValue)).””;<br />n”;
}
}
}
if(isset($_GET[‘dojs’])){
//header(“content-type:text/js”);
//$conn = mysql_connect(connect_data) or die(mysql_error());
$conn = mysql_connect(/*you can’t see me*/) or die(mysql_error());
$sel_db = mysql_select_db(“content”) or die(mysql_error());
$sql = “SELECT varname, varvalue FROM vphodata”;
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$bob = new jsVar($row);
if(!$bob->errorCheck()){
$bob->showVals();
}
}
}
?>
I commented out the header line. I think it makes sense to set different content-types based on the file type i’m getting back. although right now it’s just JS, i might send back other types at some point. Does anyone have a list of possible content types for the header function? mine doesn’t work, obviously.