Hello php freak people,
I hope you can help me solve why #30 line can not solve the problem to query to allow fetch row in php...error log show "$FirsttName" is stopped by syntax error.
Here my script:
<?php require('connection.php'); ?> <html> <head> <link href="dnocolor.css" rel="stylesheet" type="text/css"> </head> <body> <p>Welcome to Gary Taylor's DNO website</p> <p>Please register below here if you want to go</p> <form action="" method="GET"> <fieldset> <table><tr><td colspan="4" align="center">Please type your name below here:</td></tr> <tr><td>First Name:</td><td><input type="text" name="data" value="<?php if(isset($_GET['Firstname'])) echo $_GET['FirstName']; ?>"></td><td>Last Name:</td><td><input type="text" name="data" value"<?php if(isset($_GET['Firstname'])) echo $_GET['LastName']; ?>"></td></tr> <tr><td>City:</td><td><input type="text" name="data" value="<?php if(isset($_GET['City'])) echo $_GET['City']; ?>"></td><td>State:</td><td><input type="text" name="data" value="<?php if(isset($_GET['State'])) echo $_GET['State']; ?>"></td></tr> <tr><td colspan="4" align="center"><input type="submit" id="submit" value="You are going"></td></tr> </table> </fieldset> </form> <hr> <?php if($_GET){ $fon = mysqli_connect('XXXXXXX','XXXXXXXXX','XXXXXXXX','XXXXXXXX');} if($fon === false){ die("Error, could not connect ".mysqli_connect_error()); } $FirstName = mysqli_real_escape_string($fon, $_GET['FirstName']); $lastName = mysqli_real_escape_string($fon, $_GET['LastName']); $City = mysqli_real_escape_string($fon, $_GET['City']); $state = mysqli_real_escape_string($fon, $_GET['State']);
$insert = 'INSERT INTO 'XXXXXXXXXX' ('ID', 'FirstName', 'LastName', 'City', 'State') VALUES (NULL,'$FirstName','$LastName','$City','$State')';
if(mysqli_query($fon, $insert)) { echo '<p>adding your name in list successfully</p>'; } else { echo '<p>Sorry, I could not add your name to list</p>'; } $show = 'SELECT FirstName, LastName, City, State FROM XXXXXXXXX'; $result = mysql_query($show); while($row = mysql_fetch_row($result)) { echo '<table><tr><td>'.$row.'</td></tr><table>'; } ?> </body> </html>