heldenbrau Posted July 29, 2009 Share Posted July 29, 2009 I have bought a book to learn PHP. I have got to the database bit and can't get any further because I think there is something wrong with the installation. Here is the code I copied from the book and modified a bit. It is a webform where somebody creates a user id and the user id info gets written to a mysql database. When I run it on apache, nothing happens at all. I press the submit button and nothing!! no error message, it just does nothing. When I change the mysql login name to one that doesn't exist, it should die, but it doesn't. But if I miss out a ; or { then I get an error message, so it must be reading the script. <html> <title>TITLE</title> <head> <style type="text/css">@import url(styles/forms.css);</style> </head> <body> <body background="images/bg2.gif"> <br> <center> <table width = "85%" border="1" bgcolor="white" cellpadding="20"> <td style="background:url('images/scales2.gif') 50% 50% no-repeat;"> <center><h1>Create User ID</font></h1> <img src="images/image.gif"><br> <?php if (isset($POST['submit'])) { $mysqli = new mysqli("localhost", "user", "password", "user"); if ($mysqli === false) { die("ERROR: Could not connect to database. " . mysqli_connect_error()); } // open message block echo '<div id="message">'; // retrieve and check input values $inputError = false; if (empty($_POST['username'])) { echo 'ERROR: Please enter a User ID'; $inputError = true; } else { $username = $mysqli->escape_string($_POST['username']); } if ($inputError != true && empty($_POST['password'])) { echo 'ERROR: Please enter a password'; $inputError = true; } else { $password = $mysqli->escape_string($_POST['password']); } if ($inputError != true && empty($_POST['email'])) { echo 'ERROR: Please enter an email address'; $inputError = true; } else { $email = $mysqli->escape_string($_POST['email']); } $date= date("Y-m-m", mktime()); //add new user to database if ($inputError != true) { $sql = "INSERT INTO Users (username, password, rating, postnum, threadnum, joined, active, email) VALUES ($username, $password, Beginner, 0, 0, $date, n, $email)"; if ($mysqli->query($sql) === true) { echo 'Your ID has been created, you can now log in' . $mysqli ->insert_id; }else { echo "ERROR: Could not execute query: $sql. " . $mysqli->error; } } // close message block echo '</div>'; // close connection $mysqli->close(); } ?> </div> <form action="createid.php" method="POST"> Username: <input type="text" name="username" size="20" /> <p/> Password: <input type="password" name="password" size="20" /> <p/> Email Address (for verification): <input type="text" name="email" size="100" /> <p/> <input type="submit" name="submit" value="Submit" /> </form> </center> </td> </table> <br> </center> </body> </html> I am on day 2 now of trying to work out what is wrong and I think it has something to do with: In the book it says, when installing PHP find the php.ini file and alter extension_dir = "./" to read extension_dir = "c:\php\ext\" and remove the ; from extension=php_pdo.dll extension=php_sqlite.dll extension=php_mysqli.dll extension=php_pdo_sqlite.dll extension=php_pdo_mysqli.dll But, two of these lines are not even in the php.ini file and the .dll files are not even in the ext folder. The missing lines are extension=php_pdo.dll extension=php_pdo_mysqli.dll and the corresponding dll files are missing from ext folder. Does the program not working have anything to do with this? I have checked the db and no fields have been updated. Quote Link to comment https://forums.phpfreaks.com/topic/167975-solved-help-with-script-and-installation-of-php53-on-windows/ Share on other sites More sharing options...
Maq Posted July 29, 2009 Share Posted July 29, 2009 First thing's first, you need to be properly set up with all extensions that you are going to be using. To settle some confusion: But, two of these lines are not even in the php.ini file Add them. and the .dll files are not even in the ext folder. Download your extensions here, PECL, and put them in your extension directory. Make sure you restart Apache. You can run a script with just: phpinfo(); ?> to view all the extensions that have been installed. When you have all that working then come back with your relevant code and the entire error messages. Quote Link to comment https://forums.phpfreaks.com/topic/167975-solved-help-with-script-and-installation-of-php53-on-windows/#findComment-885993 Share on other sites More sharing options...
heldenbrau Posted July 29, 2009 Author Share Posted July 29, 2009 I can't find php_pdo_mysqli.dll on that site or anywhere on the internet. Quote Link to comment https://forums.phpfreaks.com/topic/167975-solved-help-with-script-and-installation-of-php53-on-windows/#findComment-886147 Share on other sites More sharing options...
wildteen88 Posted July 29, 2009 Share Posted July 29, 2009 There is no extension called php_pdo_mysqli.dll only php_pdo_mysql.dll Quote Link to comment https://forums.phpfreaks.com/topic/167975-solved-help-with-script-and-installation-of-php53-on-windows/#findComment-886155 Share on other sites More sharing options...
heldenbrau Posted July 29, 2009 Author Share Posted July 29, 2009 This is down to a printing error in the book then. It is actually not my fault, yay!! Do you think that not activating that dhl is causing my woes? I will find out soon, I bet it still does the same thing. Quote Link to comment https://forums.phpfreaks.com/topic/167975-solved-help-with-script-and-installation-of-php53-on-windows/#findComment-886338 Share on other sites More sharing options...
heldenbrau Posted July 29, 2009 Author Share Posted July 29, 2009 I've updated the PHP config file and run that info program. All the dll's come up on the table ,like Mysqli comes up with a table reporting cache and things. So looks as if everything is running ok. But still nothing happens when I press submit. Quote Link to comment https://forums.phpfreaks.com/topic/167975-solved-help-with-script-and-installation-of-php53-on-windows/#findComment-886350 Share on other sites More sharing options...
PFMaBiSmAd Posted July 29, 2009 Share Posted July 29, 2009 This - if (isset($POST['submit'])) { should be - if (isset($_POST['submit'])) { Quote Link to comment https://forums.phpfreaks.com/topic/167975-solved-help-with-script-and-installation-of-php53-on-windows/#findComment-886354 Share on other sites More sharing options...
heldenbrau Posted July 29, 2009 Author Share Posted July 29, 2009 Yes!! that is it, that is what has caused all this. Now I have error messages, thanks for your help. Will be back for more soon. I'll take back the yay! from my earlier post, because missing the $POST for 2 days is definitely not a yay it is something else. Quote Link to comment https://forums.phpfreaks.com/topic/167975-solved-help-with-script-and-installation-of-php53-on-windows/#findComment-886364 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.