I have a script which works fine on most web servers. On GoDaddy and another, it won't work. Strangely, SQL INSERTs don't work on this page. The Exact same SQL INSERTs work fine when the connection to the database is made on the same page. In my script, the connection is made in an included file. Why could this be? I've debugged and the connection code is being run before the INSERT. For example, this works: $dbConnection = mysql_pconnect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db(DATABASE_NAME, $dbConnection); $insert_question_query_sql = "insert into qa_questions (questionid, content) values ('123', 'abc')"; mysql_query($insert_question_query_sql) or die ('Error Inserting Data into the Database!') ; PHP: But when the main file includes a config.php file then the file with the SQL in, it won't work. I've tried adding this to the top: ini_set('display_errors','1'); ini_set('display_startup_errors','1'); error_reporting (E_ALL); PHP: But it tells me nothing. Any ideas?
You could change the code to this: mysql_query($insert_question_query_sql) or die ('Error Inserting Data into the Database!<br />Message from DB: '.mysql_error()) ; PHP: Then you can see whether MySQL raises an error...
Thanks for the help. Here: the MySQL error: I'm using include('config.php'); My page (index.php) includes application_top.php. application_top.php includes config.php (which hold dbase settings) application_top.php then connects to the DB. index.php then includes import.php which in turn includes import_data.php. import_data.php runs the SQL. I tried echoing out as the database is connected to: success. I also echoed out dbase settings as the SQL is being performed: success. There isn't a problem with my including. Besides, this script works on 95% of web hosts.
Well... would be strange, but does it work like this? mysql_query($insert_question_query_sql, $dbConnection) or die ('Error Inserting Data into the Database!<br />Message from DB: '.mysql_error()) ; PHP:
have you tried using mysql_connect instead of a persistent connection? Are you sure your connection string is correct? What type of account are you using? All shared hosting plans do not allow making remote connections to servers not owned by GoDaddy. So if you're trying to connect to a db server other than the ones provided by GoDaddy, it's not going to work. I've never had a problem with database servers provided by GoDaddy.
Yep, still won't work Yep, select statements work fine. Even one on the same page. All on the same database connection. It's a paid shared account It's Godaddy's database. As I said, the select statements are ok.