Daveyboy Posted December 21, 2006 Share Posted December 21, 2006 This is a problem I have been trying to troubleshoot for some time. I installed Wamp and able to render .php pages, however, I cannot insert data into Mysql database. I am able to insert via the SQL console with the same query, but mysql_query does not insert into database. No mysql errors given, script completes, checked php and mysql log and nothing, errors aren't suppressed. Maybe something to do with the php.ini file? Here is the databasetest script and php.ini that I am using;http://pastebin.ca/287214http://pastebin.ca/287218Any help would be apperciated. Link to comment https://forums.phpfreaks.com/topic/31460-solved-phpini/ Share on other sites More sharing options...
trq Posted December 21, 2006 Share Posted December 21, 2006 Try this and let us know the output.[code=php:0]<?php DEFINE ('DB_USER','root'); DEFINE ('DB_PASSWORD','password'); DEFINE ('DB_HOST','localhost'); DEFINE ('DB_NAME','phptestdatabase'); mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) OR die ('Could not connect to MySql:'. my_sql_error() ); mysql_select_db (DB_NAME) or die ('Could not select the database:'. mysql_error()); $query = "INSERT INTO info (firstname,lastname,age) VALUES ('jill', 'smith', '39')"; if (mysql_query($query)) { echo "this should work"; } else { mysql_error(); }?>[/code] Link to comment https://forums.phpfreaks.com/topic/31460-solved-phpini/#findComment-145734 Share on other sites More sharing options...
Daveyboy Posted December 22, 2006 Author Share Posted December 22, 2006 Strangely, nothing happens no mysql error or no "this should work", just a blank window in firefox. Made sure all services were active, tested phpinfo.php (good), checked php and mysql log files but nothing in there. This is my phpinfo;http://pastebin.ca/288242 Link to comment https://forums.phpfreaks.com/topic/31460-solved-phpini/#findComment-146224 Share on other sites More sharing options...
trq Posted December 22, 2006 Share Posted December 22, 2006 Try this then...[code]<?php error_reporting(E_ALL); DEFINE ('DB_USER','root'); DEFINE ('DB_PASSWORD','password'); DEFINE ('DB_HOST','localhost'); DEFINE ('DB_NAME','phptestdatabase'); mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) OR die ('Could not connect to MySql:'. my_sql_error() ); mysql_select_db (DB_NAME) or die ('Could not select the database:'. mysql_error()); $query = "INSERT INTO info (firstname,lastname,age) VALUES ('jill', 'smith', '39')"; if (mysql_query($query)) { echo "this should work"; } else { mysql_error(); }?>[/code] Link to comment https://forums.phpfreaks.com/topic/31460-solved-phpini/#findComment-146228 Share on other sites More sharing options...
Daveyboy Posted December 22, 2006 Author Share Posted December 22, 2006 nope, same thing, blank page. Changed the password to a 'false' pswd and got appropriate Mysql error. Link to comment https://forums.phpfreaks.com/topic/31460-solved-phpini/#findComment-146230 Share on other sites More sharing options...
trq Posted December 22, 2006 Share Posted December 22, 2006 Oops. Its gotta be...[code=php:0]echo mysql_error();[/code] Link to comment https://forums.phpfreaks.com/topic/31460-solved-phpini/#findComment-146239 Share on other sites More sharing options...
Daveyboy Posted December 22, 2006 Author Share Posted December 22, 2006 ok thanks dood, it was a duplicate entry problem in the database for lastname, appreciate your help! Link to comment https://forums.phpfreaks.com/topic/31460-solved-phpini/#findComment-146249 Share on other sites More sharing options...
trq Posted December 22, 2006 Share Posted December 22, 2006 Silly mistake on part. Link to comment https://forums.phpfreaks.com/topic/31460-solved-phpini/#findComment-146251 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.