Hello, $myData = $_REQUEST['data']; $xmltag = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"; print $xmltag; print '<mydata>'; require('../DBtest.php'); $host = '*******'; $userid = '*******'; $password = '*******'; $db = mysql_perry_pconnect($host, $userid, $password); if() { echo 'Error: Could not connect to database. Please try again later.'; exit; } $names = explode("|", $myData); $firstName = $names[0]; $lastName = $names[1]; $fullName = $firstName . " " . $lastName; $dbname = '7phpmysql7'; $dbtest = mysql_perry_select_db($dbname); $query = "SELECT year_recorded, hours_slept FROM ajax_sleptdata WHERE fullname = " . $fullName . "; $result = mysql_query($query); $xml_element = ""; if(!empty($result)) { $valid = "false"; $numofresults = mysql_num_rows($result); if($numofresults > 0) { for($counter = 1; $counter <= $numofresults; $counter++) { $row = mysql_fetch_array($result); $dbfullname = $row['fullname']; $year = $row['year_recorded']; $hours = $row['hours_slept']; if($fullName == $dbfullname) { $valid = "true"; } $xml_element = "<personal_data><fullname>".$dbfullname."</fullname><year_recorded>".$year."</year_recorded><hours_slept>".$hours."</hours_slept><valid>".$valid."</valid></personal_data>"; print $xml_element; } } print "</mydata>"; } PHP: I have been playing with ajax and php. I'm connecting to a database, using a mysql query, and passing information from php to ajax, by printing out the data in a xml like this... print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"; PHP: In ajax I pull the data from the xml file and display the data in a table. When I compile the php file, I receive this error... I have been searching different forums, and find people with a similar problem, but none of it is relative enough to help me. Any thoughts? Thank you.
Try using: $xmltag = '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>'; Code (markup):
Are you sure that's the line throwing the error? (Usually you get a line number at the end of the error message.)
This is probably not what casuses the error, but you have this line in your code: $dbfullname = $row['fullname']; but you don't retrive fullname from the DB. Try change it to: $dbfullname = $fullname; (since you get the fullname variable earlier in your code). Yeah. I noticed something else to: if() { echo 'Error: Could not connect to database. Please try again later.'; exit; } try: if($db) { echo 'Error: Could not connect to database. Please try again later.'; exit; } Start with these changes and we'll go from there...