Shadowing Posted November 27, 2011 Share Posted November 27, 2011 I'm using XAMPP and im a major noob. Last nite I was following this tutor and the connection script that was on it didnt work for me. So today I tried a connection script from another tutor on another site that worked just fine. here is the script that worked I saved it as test.php and went to localhost/test/php and it loaded a page connected to mysql <?php mysql_connect("localhost", "shadowing", "eguitars8") or die(mysql_error()); echo "Connected to MySQL<br />"; ?> The script that didnt work i saved it as connect.php and went to localhost/connect/php and it gave me a page saying "Object not found error "the request url was not found on this server." I understand this script doesnt have a echo on it but shouldnt it still take me to a blank white page instead of a error page. Or is there something wrong with it. Really appreciate any help with this. the script that didnt work is below <?php $mysql_server = "localhost"; // localhost is common on most hosts. $mysql_user = "shadowing"; // this is the name of your username of the server. $mysql_password = "eguitars8"; // the password connected to the username. MAKE IT COMPLEX. $mysql_database = "spacewars"; // the database name of where to connect to and where the information will be help. $connection = mysq1_connect("$mysql_server","$mysql_user","$mysql_password") or die ("Unable to establish a DB connection"); $db = mysql_database("$mysql_database") or die ("Unable to establish a DB connection"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/251874-connection-issue-with-this-script/ Share on other sites More sharing options...
MasterACE14 Posted November 27, 2011 Share Posted November 27, 2011 there's a typo in your connect.php: $connection = mysq1_connect it has a one instead of 'L' $connection = mysql_connect Quote Link to comment https://forums.phpfreaks.com/topic/251874-connection-issue-with-this-script/#findComment-1291507 Share on other sites More sharing options...
Shadowing Posted November 27, 2011 Author Share Posted November 27, 2011 Thanks alot i made that change. I still get the error page though a white page is what I should be getting right? Quote Link to comment https://forums.phpfreaks.com/topic/251874-connection-issue-with-this-script/#findComment-1291509 Share on other sites More sharing options...
Shadowing Posted November 27, 2011 Author Share Posted November 27, 2011 Two things I dont understand on the script that doesnt work is the last two command lines connection and db Db is the data base im using? and not sure what connection is Quote Link to comment https://forums.phpfreaks.com/topic/251874-connection-issue-with-this-script/#findComment-1291511 Share on other sites More sharing options...
Shadowing Posted November 27, 2011 Author Share Posted November 27, 2011 thanks I fixed my problem. Had two things going wrong at the same time. one was the 1 instead of the l and the other was apparently i cant put the script in a folder dir htdocs/spacewars I had to have the script in just htdocs I have one more issue though for kicks and grins I decided to add the command line echo "Connected to MySQL<br />"; to the script and it only works if I put it before $db. it doesnt work when i put it after the $db line. Any ideas? it still connects either way just doesnt show the echo <?php $mysql_server = "localhost"; // localhost is common on most hosts. $mysql_user = "shadowing"; // this is the name of your username of the server. $mysql_password = "eguitars8"; // the password connected to the username. MAKE IT COMPLEX. $mysql_database = "spacewars"; // the database name of where to connect to and where the information will be help. $connection = mysql_connect("$mysql_server","$mysql_user","$mysql_password") or die ("Unable to establish a DB connection"); $db = mysql_database("$mysql_database") or die ("Unable to establish a DB connection"); echo "Connected to MySQL<br />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/251874-connection-issue-with-this-script/#findComment-1291518 Share on other sites More sharing options...
kicken Posted November 27, 2011 Share Posted November 27, 2011 There is no such function mysql_database. As such your script likely is failing with a fatal error to an undefined function. If your not seeing this error in your browser, then your server must be configured to not display errors (display_errors setting in php.ini) or some other configuration issue is preventing them from showing. Quote Link to comment https://forums.phpfreaks.com/topic/251874-connection-issue-with-this-script/#findComment-1291530 Share on other sites More sharing options...
Shadowing Posted November 27, 2011 Author Share Posted November 27, 2011 Hey Kitchen Thanks soooo much. yah i had to disable errors when I installed Joomla cause of some known bug in it. Now that I enabled error it is showing the error now on that line. This at least gives me a step in a direction of trying to solve my problem now. thanks alot. No idea why this tutor i have been following and others have no problems with using that command here is the link to the tutor i have been follow if anyone wants to try to help me figure out what is going on. would appreicate it alot thanks http://www.dreamincode.net/forums/topic/184431-text-based-mafia-game-database-with-connection-part-1/ Quote Link to comment https://forums.phpfreaks.com/topic/251874-connection-issue-with-this-script/#findComment-1291534 Share on other sites More sharing options...
Shadowing Posted November 27, 2011 Author Share Posted November 27, 2011 Ahh its suppose to be mysql_select_db instead of mysql_database Now i im error free. Now i have to figure out why the next part of the tutor doesnt work for me major help Kitchen thanks again Quote Link to comment https://forums.phpfreaks.com/topic/251874-connection-issue-with-this-script/#findComment-1291537 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.