Jump to content

Connection issue with this script


Shadowing

Recommended Posts

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");

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/251874-connection-issue-with-this-script/
Share on other sites

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 />";

?>

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.

 

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/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.