jimmyb29 Posted October 5, 2014 Share Posted October 5, 2014 I'm getting an error with this code: <?php // CONNECT TO THE SERVER AND SELECT DATABASE $server = "/home/users/web/b2713/ipg.jimmybryantnet"; $user = "jimmyb29"; $password = "alfiep69"; $dataBase = "guestbook"; $conx = mysql_connect($server,$user,$password); $db_selected = mysql_select_db($dataBase,$conx); if($conx && $db_selected){ // IF CONNECTION IS ESTABLISHED $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; $xml .= "<data>\n"; if(isset($_POST['name'])){ $result = 0; $name=mysql_escape_string(trim($_POST['name'])); $email=mysql_escape_string(trim($_POST['email'])); $message=mysql_escape_string(trim($_POST['message'])); // ADD DATA TO THE TABLE guestbook WHEN THE USER PRESS THE send_btn in FLASH $sql="INSERT INTO guestbook(name,email,message,dateAdded)values('$name','$email','$message',now())"; $query = mysql_query($sql,$conx); if ($query){ $result= 1; $sql2 = "SELECT * FROM guestbook ORDER BY id DESC"; $query2 = mysql_query($sql2,$conx); //WHEN query == true , GET LIST OF MESSAGES AND PUT THEM AS XML FILE while($data = mysql_fetch_array($query2)){ $xml .= "<guest>\n"; $xml .= "<name>".$data['name']."</name>\n"; $xml .= "<msg><![CDATA[".$data['message']."]]></msg>\n"; $xml .= "<sdate>".$data['dateAdded']."</sdate>\n"; $xml .= "</guest>\n"; } } else{ $result=0; } $xml .= "<inserted>".$result."</inserted>\n"; } if(isset($_POST['getMessage'])){ // GET LIST OF MESSAGES AND PUT THEM AS XML FILE $sql = "SELECT * FROM guestbook ORDER BY id DESC"; $query = mysql_query($sql,$conx); while($data = mysql_fetch_array($query)){ $xml .= "<guest>\n"; $xml .= "<name>".$data['name']."</name>\n"; $xml .= "<msg><![CDATA[".$data['message']."]]></msg>\n"; $xml .= "<sdate>".$data['dateAdded']."</sdate>\n"; $xml .= "</guest>\n"; } } $xml .= "</data>\n"; echo $xml; } else{ // IF CONNECTION == false OR DATABASE DOESN'T EXISTE die (mysql_error()); } ?> The error message says, "error in line 10, character 17". I don't understand Thanks! Jimmy Link to comment Share on other sites More sharing options...
jcbones Posted October 5, 2014 Share Posted October 5, 2014 Copy the exact error, because this script gives me no syntax errors. Link to comment Share on other sites More sharing options...
jimmyb29 Posted October 6, 2014 Author Share Posted October 6, 2014 Hi, I sent a post yesterday, but included the wrong code! Here's the problem: <?xml version="1.0" encoding="utf-8" ?> <configuration> <phpURL>/home/users/web/b2713/ipg.jimmybryantnet?> <alert_color>#FF0000</alert_color> <name_color>#8d2405</name_color> <message_color>#532b2b</message_color> <datePosted_color>#307a03</datePosted_color> <insert_ok><![CDATA[<font color='#0f5711'>Thanks for the message.</font>]]></insert_ok> <insert_error><![CDATA[<font color='#ff0000'>Error adding Message</font>]]></insert_error> </configuration> The error message says: mismatch error line 11, Col 17. Please help. Jimmy Link to comment Share on other sites More sharing options...
aub Posted October 6, 2014 Share Posted October 6, 2014 You forgot to close phpURL tag? Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 6, 2014 Share Posted October 6, 2014 The error you are getting is not a PHP error but an XML error, most likely due to the XML being generated is invalid. Link to comment Share on other sites More sharing options...
jimmyb29 Posted December 13, 2014 Author Share Posted December 13, 2014 This seems to be the culprit now; It's the Guestbook code: I get an error message that says there's an unexpected T_String error in line 5. <?php // CONNECT TO THE SERVER AND SELECT DATABASE $server = ' < $link = mysqli_connect( <?php $link = mysqli_connect('jimmybryantnet.ipagemysqli.com', 'jimmyb29', '*******'); if (!$link) { die('Could not connect: ' . mysqli_error()); } echo 'Connected successfully'; mysqli_select_db(guestbook); ?> ); if (!$link) { die('Could not connect: ' . mysqli_error()); echo 'Connected successfully'; mysqli_select_db(guestbook); ?> '; $user = 'jimmyb29'; $password = 'alfiep69'; $dataBase = 'guestbook'; $conx = mysqli_connect($server,$user,$password); $db_selected = mysqli_select_db($dataBase,$conx); if($conx && $db_selected){ // IF CONNECTION IS ESTABLISHED $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; $xml .= "<data>\n"; if(isset($_POST['name'])){ $result = 0; $name=mysqli_escape_string(trim($_POST['name'])); $email=mysqli_escape_string(trim($_POST['email'])); $message=mysqil_escape_string(trim($_POST['message'])); // ADD DATA TO THE TABLE guestbook WHEN THE USER PRESS THE send_btn in FLASH $sql="INSERT INTO guestbook(name,email,message,dateAdded)values('$name','$email','$message',now ())"; $query = mysqil_query($sql,$conx); if ($query){ $result= 1; $sql2 = "SELECT * FROM guestbook ORDER BY id DESC"; $query2 = mysql_query($sql2,$conx); //WHEN query == true , GET LIST OF MESSAGES AND PUT THEM AS XML FILE while($data = mysqli_fetch_array($query2)){ $xml .= "<guest>\n"; $xml .= "<name>".$data['name']."</name>\n"; $xml .= "<msg><![CDATA[".$data['message']."]]></msg>\n"; $xml .= "<sdate>".$data['dateAdded']."</sdate>\n"; $xml .= "</guest>\n"; } } else{ $result=0; } $xml .= "<inserted>".$result."</inserted>\n"; } if(isset($_POST['getMessage'])){ // GET LIST OF MESSAGES AND PUT THEM AS XML FILE $sql = "SELECT * FROM guestbook ORDER BY id DESC"; $query = mysqli_query($sql,$conx); while($data = mysqli_fetch_array($query)){ $xml .= "<guest>\n"; $xml .= "<name>".$data['name']."</name>\n"; $xml .= "<msg><![CDATA[".$data['message']."]]></msg>\n"; $xml .= "<sdate>".$data['dateAdded']."</sdate>\n"; $xml .= "</guest>\n"; } } $xml .= "</data>\n"; echo $xml; } Thanks! Link to comment Share on other sites More sharing options...
hansford Posted December 13, 2014 Share Posted December 13, 2014 The code seems a bit jumbled. <?php // CONNECT TO THE SERVER AND SELECT DATABASE // not needed $server = ' < // not needed $link = mysqli_connect( <?php ' // mysqli_connect($host, $user, $password, $database); // change $link = mysqli_connect('jimmybryantnet.ipagemysqli.com', 'jimmyb29', '*******'); if (!$link) { die('Could not connect: ' . mysqli_error()); } echo 'Connected successfully'; // not needed mysqli_select_db(guestbook); // not needed ?> ); // not needed if (!$link) { die('Could not connect: ' . mysqli_error()); // not needed echo 'Connected successfully'; // not needed mysqli_select_db(guestbook); // not needed ?> '; // appears to be making a redundant connection to the same database, so // not needed here - should be defined at top of page $user = 'jimmyb29'; // not needed here - should be defined at top of page $password = 'alfiep69'; // not needed here - should be defined at top of page$dataBase = 'guestbook'; // not needed $conx = mysqli_connect($server,$user,$password); // not needed $db_selected = mysqli_select_db($dataBase,$conx); Link to comment Share on other sites More sharing options...
mac_gyver Posted December 13, 2014 Share Posted December 13, 2014 you also already have a thread from Dec 8th/9th for the php error and php code you just added to the end of this thread. this topic is locked. Link to comment Share on other sites More sharing options...
Recommended Posts