j05hr Posted October 4, 2008 Share Posted October 4, 2008 my problem is that when i upload any php to my server it doesn't work, with this simple test code it comes out blank on the page when i upload it to the server maybe it's my login information that's wrong or maybe the code or maybe i'm putting the code in the wrong location when i upload it. or maybe my database is wrong. any help will be appreciated i have two bits of code one called dbconncect.php dbtest.php <?php DEFINE ('HOST', 'jasongold.org'); DEFINE ('USER', 'user'); DEFINE ('PASS', 'example'); DEFINE ('MYDB', 'jason_gold'); ?> and another one just a test dbconnect.php <?php require_once('../../dbconnect.php'); error_reporting(E_ALL); $dbc = mysql_connect(HOST, USER, PASS) OR die("Unable to connect to database: " . mysql_error()); mysql_select_db(MYDB) OR die("Unable to select database: " . mysql_error($dbc)) $query = "INSERT INTO jason_gold (name, email_address) VALUES ('Kevin', 'kevin@gmail.com')"; $result = mysql_query($query); if(mysql_affected_rows() == 1) { echo "Insert successful!"; } else { echo "Something went wrong!"; } ?> image of database Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/ Share on other sites More sharing options...
waynew Posted October 4, 2008 Share Posted October 4, 2008 Try: <?php error_reporting(E_ALL); require_once('../../dbconnect.php'); $dbc = mysql_connect(HOST, USER, PASS) OR die("Unable to connect to database: " . mysql_error()); mysql_select_db(MYDB) OR die("Unable to select database: " . mysql_error($dbc)) $query = "INSERT INTO jason_gold (name, email_address) VALUES ('Kevin', 'kevin@gmail.com')"; $result = mysql_query($query); if(mysql_affected_rows() == 1) { echo "Insert successful!"; } else { echo "Something went wrong!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-656928 Share on other sites More sharing options...
j05hr Posted October 4, 2008 Author Share Posted October 4, 2008 still getting a blank screen, when i type in a filename i haven't uploaded i get the message Not Found The requested URL /fthth.php was not found on this server. which means it must recognise it at it comes up blank? also when i type in another bit of php i've done i get the message Database connection failed: Access denied for user 'root'@'localhost' (using password: YES) so again it recognises it but doesn't work either Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-656935 Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2008 Share Posted October 4, 2008 Put both of the following lines immediately after your first <?php tag (display_errors is probably and should be OFF on a live server) - ini_set ("display_errors", "1"); error_reporting(E_ALL); Also, have you tested this code first on a local development system so that you know it is free of parse errors? Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-657040 Share on other sites More sharing options...
j05hr Posted October 4, 2008 Author Share Posted October 4, 2008 i hadn't actually tested it on a local server yet which was silly. i got this error for it Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\test\dbtest.php on line 7 i had also changed my code back to how it was originally so this is what it was, i think the error message has something to do with my database. <?php require_once('../../dbconnect.php'); $dbc = mysql_connect(HOST, USER, PASS) OR die("Unable to connect to database: " . mysql_error()); mysql_select_db(MYDB) OR die("Unable to select database: " . mysql_error($dbc)) $query = "INSERT INTO jason_gold (name, email_address) VALUES ('Kevin', 'kevin@gmail.com')"; $result = mysql_query($query); if(mysql_affected_rows() == 1) { echo "Insert successful!"; } else { echo "Something went wrong!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-657129 Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2008 Share Posted October 4, 2008 There is a missing semi-colon ; on the end of line 5 of the posted code. Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-657136 Share on other sites More sharing options...
j05hr Posted October 4, 2008 Author Share Posted October 4, 2008 i now get this error Warning: require_once(../../dbconnect.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\test\dbtest.php on line 2 Fatal error: require_once() [function.require]: Failed opening required '../../dbconnect.php' (include_path='.;C:\php5\pear') in C:\wamp\www\test\dbtest.php on line 2 is it saying the dbconnect file doesn't exsist? Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-657137 Share on other sites More sharing options...
j05hr Posted October 4, 2008 Author Share Posted October 4, 2008 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-657155 Share on other sites More sharing options...
j05hr Posted October 4, 2008 Author Share Posted October 4, 2008 i'm now using a different bit of code to upload and i get this message Database selection failed: Unknown database 'widget_corp' i know the database definately exsists because i used it on the local machine and it worked fine but when i upload it to the server it says it doesn't recognise it. www.jasongold.org/index.php Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-657187 Share on other sites More sharing options...
j05hr Posted October 5, 2008 Author Share Posted October 5, 2008 still can't get it to work the error message being Database selection failed: Unknown database ' widget_corp' the database definately exsists here's the code constants.php <?php // Database Constants define("DB_SERVER", 'localhost'); define("DB_USER", 'root); define("DB_PASS", 'example'); define("DB_NAME", 'widget_corp'); ?> connection.php <?php require("constants.php"); // 1. Create a database connection $connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS); if (!$connection) { die("Database connection failed: " . mysql_error()); } // 2. Select a database to use $db_select = mysql_select_db(DB_NAME,$connection); if (!$db_select) { die("Database selection failed: " . mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-657334 Share on other sites More sharing options...
JasonLewis Posted October 5, 2008 Share Posted October 5, 2008 You're missing closing ' in your definitions. On User and Name. Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-657336 Share on other sites More sharing options...
j05hr Posted October 5, 2008 Author Share Posted October 5, 2008 that was just a typo as i changed it so people couldn't see the real username and password so the problem still persists Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-657337 Share on other sites More sharing options...
KevinM1 Posted October 6, 2008 Share Posted October 6, 2008 In your constants.php file, change 'widget_corp' to your actual database name, 'jason_gold.' Quote Link to comment https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/#findComment-658009 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.