Help

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Kintama
Posts: 50
Joined: Mon Nov 16, 2009 9:41 pm

Help

Post by Kintama »

ok so im on the 2nd tutorial at the end of it and when i shud get player1's email all i get is {no db}
this is my scripts
________________________Connect.php______________________________

Code: Select all

<?php

$db = mysql_connect ("localhost" , "usernam" , "password") or die ("Could not connect to db");
if ( $db)
 die ("no db");
if ( mysql_select_db ("tutorial",$db))
 die ("No Database Selected");
 
?>
_________________________________test.php

Code: Select all

<?php
include 'connect.php';

$playerinfo ="select ' from players where name = 'player1'";
$playerinfo2 = mysql_query($playerinfo) or die ("Could not Select Players");
$playerinfo3 = mysql_fetch_array($playerinfo2);

echo "Player1's email is " . $playerinfo3['email'];

?>
i have triple checked the vidoes and my scrips and its all correct on what i can see
Last edited by Kintama on Tue Nov 17, 2009 6:32 pm, edited 1 time in total.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Help

Post by SpiritWebb »

In your test.php file on the line $playerinfo="select ' from...

It should read:

connect.php

Code: Select all

<?php

$db = mysql_connect("localhost","root","") or die("Could not connect to db");
if(!$db)
die("no db");
if(!mysql_select_db("tutorial",$db))
die("No Database Selected");

?>
test.php

Code: Select all

<?php
include 'connect.php';

$playerinfo = "SELECT * from players where name = 'player1'";
$playerinfo2 = mysql_query($playerinfo) or die ("Could not select players");
$playerinfo3 = mysql_fetch_array($playerinfo2);

echo "Player1's email is: " . $playerinfo3['email'];

?>
You used ' instead of *. You also need to make sure you created the db in MySql that says "tutorial." If you used another name other then tutorial, then you need to change "tutorial" over to whatever you used.
Image

Image
Kintama
Posts: 50
Joined: Mon Nov 16, 2009 9:41 pm

Re: Help

Post by Kintama »

oooo i see thanks againe :P ill check it now
Last edited by Kintama on Tue Nov 17, 2009 6:27 pm, edited 1 time in total.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Help

Post by SpiritWebb »

Sure thing...hope that helps you out!! :)
Image

Image
Kintama
Posts: 50
Joined: Mon Nov 16, 2009 9:41 pm

Re: Help

Post by Kintama »

ooo i still get the same text no change in it

can we speak on MSN
kintama@live.co.uk
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Help

Post by hallsofvallhalla »

missing a 'e' on username in the first script...
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Help

Post by SpiritWebb »

Oh hell, I didn't even see the "e" on username...blah
Image

Image
Kintama
Posts: 50
Joined: Mon Nov 16, 2009 9:41 pm

Re: Help

Post by Kintama »

username and password on my DB database bit it not the real info cuz i have other stuff on my database :P
so i dont no what is wrong with it
Kintama
Posts: 50
Joined: Mon Nov 16, 2009 9:41 pm

Re: Help

Post by Kintama »

is this 100% right

Code: Select all

<?php

$db = mysql_connect ("localhost" , "my username" , "my password") or die ("Could not connect to db");
if ($db)
 die ("no db");
if ( mysql_select_db ("tutorial",$db))
 die ("No Database Selected");
 
?>
and were it ses

Code: Select all

if ($db)
 die ("no db");
if ( mysql_select_db ("tutorial",$db))
is looks think there is somethink on your video were it ses if ({look like there some think here}$db)
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Help

Post by SpiritWebb »

in your connect.php file should look:

Code: Select all

<?php

$db = mysql_connect("localhost","my username","my password") or die("Could not connect to db");  
if(!$db)
die("no db");
[b]if(!mysql_select_db("tutorial",$db))[/b]  //You left out the ! in front of the mysql_select_db statement //
die("No Database Selected");

?>
You can try taking out all the spaces in your code on each line, except between the $db = mysql part. Thats how I have on mine, but then again, I dont have a username or password on my localhost. I just use ("localhost","root","")
Image

Image
Post Reply

Return to “Advanced Help and Support”