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

?>

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.