Browser MMO Video#2
-
- Posts: 24
- Joined: Tue Oct 20, 2009 3:00 pm
Re: Video#2
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"?
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"?
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#2
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;
like $db = 0;
-
- Posts: 24
- Joined: Tue Oct 20, 2009 3:00 pm
Re: Video#2
$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
$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
- Lord Strife
- Posts: 104
- Joined: Wed Oct 28, 2009 3:10 pm
Re: Video#2
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:
examples:
Code: Select all
$db = '0';
or
@$db = 0;
-
- Posts: 24
- Joined: Tue Oct 20, 2009 3:00 pm
Re: Video#2
<?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.
$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.
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#2
nice work on the catch
so its fixed completely?
so its fixed completely?
-
- Posts: 24
- Joined: Tue Oct 20, 2009 3:00 pm
Re: Video#2
Yes indeed, the notice is gone.
Re: Video#2
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
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
Re: Video#2
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
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
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#2
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.