Hi i have a little problem with the database well a question? what do i do with it like where do i add that code you gave? Do i make a database.php ? i am using 000webhost right now i looked around but i just dont get it. if yu can tell me where to put it and what to name it i would appreciate it. thanks in ahead
Text Based Mafia Game || Database with Connection Part 1. Setting up a database with simple Connection
#17
Posted 22 May 2011 - 11:54 AM
nyjatt, on 16 April 2011 - 05:16 PM, said:
Hi i have a little problem with the database well a question? what do i do with it like where do i add that code you gave? Do i make a database.php ? i am using 000webhost right now i looked around but i just dont get it. if yu can tell me where to put it and what to name it i would appreciate it. thanks in ahead
hi nyjatt,
The best answer i can give you is to learn php and starting making little php scripts, use the tutorials on this site to help you out. When you have finished all the basics this will make much sense. let me know how it all goes.
#18
Posted 15 June 2011 - 11:58 AM
creativecoding, on 24 October 2010 - 10:48 PM, said:
Themitchel0, on 18 October 2010 - 04:46 PM, said:
is it possible to make a mysql database without using a server?, like can i make a local one? any help would be nice thank you!
Why did this get -rep?
Anyhow, I believe if you wanted to, you could set up a Virtual Machine (oracle has a good one) with some server software, you can add mysql to it and host your websites database. Although, your VM and computer would have to remain turned on...
Or even simpeler, WAMP
#19
Posted 26 November 2011 - 05:32 AM
Ive hit a wall its not working for me can you please help me out
my user database is all filled out. im using XAMPP
Created a folder called spacewars in the htdocs folder
This is the folder I placed connect.php and test.php in
On the connect.php script i wasnt sure what to put for connection and db? so I put mysq1_connect and mysql_database
My Database name is spacewars
server name is localhost
Username is shadowing
I type in http://localhost/spacewars/test
and I get a object not found error
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
I really appreciate the help
my user database is all filled out. im using XAMPP
Created a folder called spacewars in the htdocs folder
This is the folder I placed connect.php and test.php in
On the connect.php script i wasnt sure what to put for connection and db? so I put mysq1_connect and mysql_database
My Database name is spacewars
server name is localhost
Username is shadowing
I type in http://localhost/spacewars/test
and I get a object not found error
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
I really appreciate the help
Attached image(s)
#20
Posted 26 November 2011 - 09:35 PM
Im following another step by step tutor and there connection script works just fine but yours doesnt. Trying to figure and understand why.
<?php
mysql_connect("localhost", "shadowing", "eguitars8") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
I named that script test.php and typed in localhost/test.php and it worked saying connect to mysql
but when I do yours and type localhost/connect/php I get a Object not found error "the request url was not found on this server.
This is what i have for your connection script. I understand there is no echo in this script but shouldnt it give me a white page at least saying nothing on it?
<?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");
?>
<?php
mysql_connect("localhost", "shadowing", "eguitars8") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
I named that script test.php and typed in localhost/test.php and it worked saying connect to mysql
but when I do yours and type localhost/connect/php I get a Object not found error "the request url was not found on this server.
This is what i have for your connection script. I understand there is no echo in this script but shouldnt it give me a white page at least saying nothing on it?
<?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");
?>
#21
Posted 27 November 2011 - 01:35 AM
Alright I solved my problem.
I was putting the connect and test php file in a folder with in the dir. I use xammp so i was putting it in the dir xampp/htdocs/spacewars which is the name of my project
Also the other reason it wasnt working was because mysql_connect had a 1 in it instead of a L
and i just noticed there is no differance from a 1 and a L on this site lol looks the same almost l1 crazy
I was putting the connect and test php file in a folder with in the dir. I use xammp so i was putting it in the dir xampp/htdocs/spacewars which is the name of my project
Also the other reason it wasnt working was because mysql_connect had a 1 in it instead of a L
and i just noticed there is no differance from a 1 and a L on this site lol looks the same almost l1 crazy
#22
Posted 27 November 2011 - 03:04 AM
Oh great now i have another problem 
I cant get the test page to do anything I get a HTTP 500 Internal Server Error and says Internet instead of intranet on the bottom of my broswer using IE8.
So for kicks I created a php file with only this line of code
<?php include_once("connect.php"); ?>
and saved it as aa.php
so i run http://localhost/aa.php in my browser and i get the same error.
Shouldnt I get a blank page that is all white? like as if I ran connect.php
so its like this code doesnt even work <?php include_once("connect.php"); ?>
I"m using XAMPP the test file and the connect file is in xampp/htdocs
I cant get the test page to do anything I get a HTTP 500 Internal Server Error and says Internet instead of intranet on the bottom of my broswer using IE8.
So for kicks I created a php file with only this line of code
<?php include_once("connect.php"); ?>
and saved it as aa.php
so i run http://localhost/aa.php in my browser and i get the same error.
Shouldnt I get a blank page that is all white? like as if I ran connect.php
so its like this code doesnt even work <?php include_once("connect.php"); ?>
I"m using XAMPP the test file and the connect file is in xampp/htdocs
#23
Posted 27 November 2011 - 04:13 AM
Alright I got everything working. I will state what happend incase anyone in the future does the same mistakes I did.
On the connect script I had $db = $mysql_database("$mysql_database") instead of having $db = mysql_select_db("$mysql_database")
I had errors shut off on my apache server so I didnt see the error. Which would of solved alot of my other problems seeing errors.
After I fixed that issue I was still getting a db error. Either using <?php instead of <? fixed that or adding a space between <html > and <?php include_once("connect.php"); ?> fixed it.
Either way i double checked and using <? or not putting a space between those two lines still makes everything work. For some reason it didnt at first but now it does. lol not sure why. now i can continue the rest of the tutor. Ya!
On the connect script I had $db = $mysql_database("$mysql_database") instead of having $db = mysql_select_db("$mysql_database")
I had errors shut off on my apache server so I didnt see the error. Which would of solved alot of my other problems seeing errors.
After I fixed that issue I was still getting a db error. Either using <?php instead of <? fixed that or adding a space between <html > and <?php include_once("connect.php"); ?> fixed it.
Either way i double checked and using <? or not putting a space between those two lines still makes everything work. For some reason it didnt at first but now it does. lol not sure why. now i can continue the rest of the tutor. Ya!
#24
Posted 18 February 2012 - 04:40 PM
Denis1, on 09 September 2010 - 10:12 AM, said:
Ok this is a common error if you are using a localhost. Try using the full php tags. so instead of
<? echo "Denis"; ?>you should use
<?php echo "Denis"; ?>. Local-hosts like xampp confuse <? tage for xml and it all a big mess.
Thank you!! i spent 2 days trying to find the problem myself.
|
|






MultiQuote



|