qbkayd5tal
New Member
I want to perform javascript functions on a page after I retrieve some values from a local database. However once the PHP code is in my javascript the javascript function won't even run in the first place. If I separate the PHP code out and run the PHP code alone, it works fine, as well as the javascript code too. Here's my code:\[code\]<?mysql_connect("127.0.0.1:3307", "username", "password") or die ("Error fetching value from database.");mysql_select_db("ccmalumni");$result = mysql_query("SELECT DISTINCT value FROM ccm_bp_xprofile_data WHERE field_id = 16") or die ("What da heck");$states = db_result_array_values($result);echo $states[0];mysql_close();function db_result_array_values($result) { for ($array = array(); $row = mysql_fetch_row($result); isset($row[1]) ? $array[$row[1]] = $row[0] : $array[] = $row[0]); return $array; }?>var present = <? echo json_encode($states); ?>;\[/code\]Please, what am I doing wrong? You can see the full code here.Thanks.