Hi, I have just attempted my first php script. The script is designed to take information passed from a form on the page before it and then append it into a table in a database. However, when I run it I don't get any error messages or anything, just a blank screen. When I check the database it hasn't updated. Could someone please look through my code and tell me where I'm going wrong? Any advice would be greatly appreciated!
I recommend just adding a bit more to your error detect so it tells the error on the page. You could always disable the error later. Change your code as follows: //error checking code $dbcnx = mysql_connect('localhost', 'user', 'password'); if (!$dbcnx ) { die('Connection error: ' . mysql_error()); } /*Old Code $dbcnx = @mysql_connect('localhost', 'user', 'password'); if (!$dbcnx) { exit('<p>Unable to connect to the database server at this time.</p>'); } if (!mysql_select_db('mydb')) { exit('<p>Unable to locate the krabople database at this time.</p>'); }*/ PHP: Then again the problem might not be in your connection. So change the code down here.. //Error Detection Code $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } /* Old Code if(@mysql_query($sql)) { echo '<p>Your registration was successful!</p>'; } else { echo '<p>There was an error while processing your registration: ' . mysql_error() . '</p>'; } }*/ PHP: This should allow you to figure it out yourself.. If you still have a problem post a bit more about it along with the error code.
Hi, thanks for the advice. However, I have tried changing the code as suggested and nothing happens. The annoying thing is that there is no error message whatsoever, just a blank screen. I know that php is definitely working on my computer as I have tried deleting everything and just displaying variables using the echo command. Any idea why the screen might be completely blank? If I miss a bracket or something it tells me there is an error but it is not doing that so I presume the problem is not with the syntax
if you changed the code as I suggested you should be getting an error message. Unless you had a PHP error I didn't notice.. You are accessing the php code from within a PHP server right? Anyhow I'm sure your doing that so I would advise you to turn on your local error reporting by modifying your php.ini file. You can find documentation on that here at php.net
Says who? I avoid VALUES like the plague... SET is more readable and will work for update and insert.
Hi, thanks a lot for your help - the answer did lie in the php.ini file. I just needed to unremark the mysql.dll line - I thought I had done it but I'd done the wrong one. Code works fine now.