Browser MMO Video#2

Location of the Videos
Post Reply
RolsenRoyce
Posts: 24
Joined: Tue Oct 20, 2009 3:00 pm

Re: Video#2

Post by RolsenRoyce »

Warning message!

Notice: Use of undefined constant db - assumed 'db' in D:\wamp\www\NUKE\connect.php on line 4
$playerinfo ="select * from players where name = 'Mike Rophone'"; //this is my line 4

Code works, but I want to remove the warning message, it looks so unprofessional :>
Can I "define" this "constant db"?
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#2

Post by hallsofvallhalla »

what is your line 4 in your connect.php? you may have to define the db variable in the beginning of the code.

like $db = 0;
RolsenRoyce
Posts: 24
Joined: Tue Oct 20, 2009 3:00 pm

Re: Video#2

Post by RolsenRoyce »

$playerinfo ="select * from players where name = 'Mike Rophone'"; //this is my line 4

$db = 0; // does nothing, since it is already:
$db = mysql_connect("localhost","root","") or die("Could not connect to DB");

Notice message still stands.
And it is copypasted from videotutorial
User avatar
Lord Strife
Posts: 104
Joined: Wed Oct 28, 2009 3:10 pm

Re: Video#2

Post by Lord Strife »

if you get one of those notices you can do 2 things , first put @ in front of the db var. or two incase the db var with ' '

examples:

Code: Select all

$db = '0';
or 

@$db = 0;
RolsenRoyce
Posts: 24
Joined: Tue Oct 20, 2009 3:00 pm

Re: Video#2

Post by RolsenRoyce »

<?php
$db = mysql_connect("localhost","root","") or die("Could not connect to DB");
if(!db) // I forgot a $ on the fecher. Added it, now works (Line is now: if(!$db)
die("No DB");
if(!mysql_select_db("Silos",$db))
die("No DB Selected");
?>

I found the error.
I removed empty lines and then I got the real line number? Now it pointed at three.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#2

Post by hallsofvallhalla »

nice work on the catch

so its fixed completely?
RolsenRoyce
Posts: 24
Joined: Tue Oct 20, 2009 3:00 pm

Re: Video#2

Post by RolsenRoyce »

Yes indeed, the notice is gone.
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Video#2

Post by ZeroComp »

nice tut helped a lot more than my stupid book
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Video#2

Post by ZeroComp »

my result page says this


Player1's email is player1@indie-resource.com
Notice: Undefined index: id in C:\wamp\www\Tutorial\test.php on line 9

Player1's id is
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#2

Post by hallsofvallhalla »

check your database and make sure all feilds and data are exactly like they should be, capital letters and all. Post a screen if you need to.
Post Reply

Return to “Older Browser MMO Videos”