3raser Posted February 26, 2011 Share Posted February 26, 2011 <?php include_once("includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><? $title; ?></title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="wrap"> <div id="header"> <h1><? $title; ?></h1> <h2><? $description; ?></h2> </div> <? include_once("includes/navigation.php"); ?> <div id="content"> <div id="right"> <h2>Create</h2> <div id="artlicles"> <?php if(!$_SESSION['user']) { $username = $_POST['username']; $password = $_POST['password']; $name = $_POST['name']; $server_type = $_POST['type']; $description = $_POST['description']; if(!$username || !$password || !$server_type || !$description || !$name) { echo "Note: Descriptions allow HTML. Any abuse of this will result in an IP and account ban. No warnings! All forms are required to be filled out.<br><form action='create.php' method='POST'><table><tr><td>Username</td><td><input type='text' name='username'></td></tr><tr><td>Password</td><td><input type='password' name='password'></td></tr>"; echo "<tr><td>Sever Name</td><td><input type='text' name='name' maxlength='35'></td></tr><tr><td>Type of Server</td><td><select name='type'> <option value='Any'>Any</option> <option value='PvP'>PvP</option> <option value='Creative'>Creative</option> <option value='Survival'>Survival</option> <option value='Roleplay'>RolePlay</option> </select></td></tr> <tr><td>Description</td><td><textarea maxlength='1500' rows='18' cols='40'></textarea></td></tr>"; echo "<tr><td>Submit</td><td><input type='submit'></td></tr></table></form>"; } elseif(strlen($password) < { echo "Password needs to be higher than 8 characters!"; } elseif(strlen($username) > 13) { echo "Username can't be greater than 13 characters!"; } else { $check1 = $db->prepare("SELECT username,name FROM servers WHERE username = ? OR name = ? LIMIT 1"); $check1->execute(array($username, $name)); if($check1->rowCount() > 0) { echo "Sorry, there is already an account with this username and/or server name!"; } else { $ip = $_SERVER['REMOTE_ADDR']; $insertQuery = $db->prepare("INSERT INTO servers (id, username, password, name, type, description, ip, votes, beta) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $insertQuery->execute(array(null, $username, $password, $name, $server_type, $description, $ip, 0, 1)); if($insertQuery->errorInfo() > 0) { echo "Sorry, there was the following error:"; print_r($insertQuery->errorInfo()); } else { echo "Server has been succesfully created!"; } } } } else { echo "You are currently logged in!"; } ?> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <a href="http://www.templatesold.com/" target="_blank">Website Templates</a> by <a href="http://www.free-css-templates.com/" target="_blank">Free CSS Templates</a> - Site Copyright MCTop </div> </div> </body> </html> Whats wrong with that page? :/ Quote Link to comment https://forums.phpfreaks.com/topic/228952-why-doesnt-my-insert-query-work/ Share on other sites More sharing options...
harristweed Posted February 26, 2011 Share Posted February 26, 2011 You need to ask specific questions about what you are trying to achieve and what's not working. What error messages are you getting? What's not working? What have you done to rectify the problem? Quote Link to comment https://forums.phpfreaks.com/topic/228952-why-doesnt-my-insert-query-work/#findComment-1180117 Share on other sites More sharing options...
3raser Posted February 26, 2011 Author Share Posted February 26, 2011 You need to ask specific questions about what you are trying to achieve and what's not working. What error messages are you getting? What's not working? What have you done to rectify the problem? I'm not getting any error messages. The data from the INSERT query near the bottom of the code just simply isn't doing it's job, basically not sending the data to the database. And I need help to figure out why. Quote Link to comment https://forums.phpfreaks.com/topic/228952-why-doesnt-my-insert-query-work/#findComment-1180125 Share on other sites More sharing options...
jcbones Posted February 26, 2011 Share Posted February 26, 2011 Do you have de-bugging turned on in your db class? Does it even have de-bugging? Quote Link to comment https://forums.phpfreaks.com/topic/228952-why-doesnt-my-insert-query-work/#findComment-1180150 Share on other sites More sharing options...
3raser Posted February 26, 2011 Author Share Posted February 26, 2011 Do you have de-bugging turned on in your db class? Does it even have de-bugging? Yes. I used ->errorInfo() to see if theres any errors with the query. There isn't. Quote Link to comment https://forums.phpfreaks.com/topic/228952-why-doesnt-my-insert-query-work/#findComment-1180155 Share on other sites More sharing options...
jcbones Posted February 26, 2011 Share Posted February 26, 2011 echo the query, and paste it into myAdmin or whatever you use. See if it works. Quote Link to comment https://forums.phpfreaks.com/topic/228952-why-doesnt-my-insert-query-work/#findComment-1180158 Share on other sites More sharing options...
3raser Posted February 27, 2011 Author Share Posted February 27, 2011 echo the query, and paste it into myAdmin or whatever you use. See if it works. Not to sure on how to echo a the query I'm using, since it uses two different lines of code to run it. But I don't think there are any errors... :/ - errorInfo() doesn't report anything, so no need to check for more errors. Quote Link to comment https://forums.phpfreaks.com/topic/228952-why-doesnt-my-insert-query-work/#findComment-1180235 Share on other sites More sharing options...
jcbones Posted February 27, 2011 Share Posted February 27, 2011 So, it doesn't work, and you are sure it isn't a coding problem! The next step I would suggest is to stab the server with an ice-pick. Maybe you can get the little troll living inside that is stopping your script from executing properly. Quote Link to comment https://forums.phpfreaks.com/topic/228952-why-doesnt-my-insert-query-work/#findComment-1180319 Share on other sites More sharing options...
3raser Posted February 28, 2011 Author Share Posted February 28, 2011 So, it doesn't work, and you are sure it isn't a coding problem! The next step I would suggest is to stab the server with an ice-pick. Maybe you can get the little troll living inside that is stopping your script from executing properly. Er, I'm not trolling. I seriously can't get this code to work. And I don't know any way besides errorInfo() to debug this. Even when I do that, I receive no errors. If you don't want to contribute towards helping solve this, then please just leave this thread. And it IS a coding problem. Quote Link to comment https://forums.phpfreaks.com/topic/228952-why-doesnt-my-insert-query-work/#findComment-1180605 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.