tutorial failed
|
|||
|
Rank: ? (3)
Member #: 29640 |
PHP Login Script Tutorial
when i followed it and upload it to my website i get this error message. when i run the register.php Parse error: parse error, unexpected T_VARIABLE in /home/gamereli/public_html/db_connect.php on line 26 This is what my db_connect.php looks like Code:
i think that my problem is $db_object = DB::connect($datasource, TRUE); im not sure if i need to replace$datasouce with my actualy website link, followed by the name of my DB... Sum1 please help me. =========================== if you go to my website to test it dont forget to type this in after link... i have a temp .html tempalte up.. only so that people dont see my web structure.. use this to try it out http://gamerelites.com/register.php http://gamerelites.com/login.php http://gamerelites.com/logout.php PLease give me feedback » Post edited 2007-06-25, 04:07pm by relpats_eht.
|
||
|
|||
|
|||
|
Rank: ? (4821)
Member #: 3416 |
strange that db_connect.php would output html, but that might be what the tutorial tells you to do. anyway your problem is this line:
$db_name;gamereli_user it's just not valid php. a couple other logic problems are: 1. $db_host is just a server name -- not a url. usually localhost works here. 2. $db_name is the name of the database you created, but 'gamereli_user' looks more like a user name to me. if you did name the database gamereli_user when you created it, then don't worry about this. 3. you should build the $datasource string using just the $db_* variables -- you don't need to use their values again. i don't remember the exact syntax for PEAR::DB, but i think it should look something like mysql://user:pass@localhost/dbname when you're done. you can use echo $datasource after you set up the variable to make sure it looks right. hope that helps!
my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
|
||
|
|||
|
|||
|
Rank: ? (3)
Member #: 29640 |
well gamereli_user is the name of my database.
this is what my code looks like actually.. i modified it last night after this post. Code:
I tried what u said.. didnt work.. i think i didnt write it correctly.. because i was gettign the same error. IF you dont mind would you please just post a modified version of what u think it should look like.. AND THANKS SO MUCH. i apreciate your help im also kinda curious about this.. require_once 'DB.php'; should this be require_once 'gamereli_user.php'; because gamereli_user is the name of by DB » Post edited 2007-06-25, 04:01pm by relpats_eht.
|
||
|
|||
|
|||
|
Rank: ? (767)
Member #: 11085 |
Once again, your problem (as in, what is causing the error), is this line:
$db_name;'gamereli_user'. You know what to do to fix it, I trust. If you don't, stare until the answer jumps out at you (hint: it has to do with punctuation). However, even when you fix that, your code still will not work. As misterhaan has already said: 3. you should build the $datasource string using just the $db_* variables -- you don't need to use their values again. i don't remember the exact syntax for PEAR::DB, but i think it should look something like mysql://user:pass@localhost/dbname when you're done. you can use echo $datasource after you set up the variable to make sure it looks right. If you need more help there than that, take another look at the tutorial, it says exactly what you should do. On to your most recent question, require_once is a function which literally (sort of) takes another PHP file and inserts it in the place of the function call. DB.php is a file supplied by the PEAR add on to PHP which holds the database class. It is not necessary to use if you want MySQL, but it is necessary if you want to interface with MySQL with the PEAR::DB class (as you are and the tutorial suggests). Also, please don't ask us to post the modified code. You don't learn anything by completing a project, you learn by whatever journey you take to get there. If you have a problem, I would advise looking up the error codes, thinking about the logic of your program, and reading the manual for a few hours to try to fix the problem on your own first, and if you don't have the answer by then, then coming to ask us. It is tedious and it is boring, but you will learn, eventually. Lastly, and I am going way off topic here, keep in mind that, at least with programming, the road to understanding is full of long plateaus. You likely wont have the slightest idea what you are doing for months. Keep doing as I suggested anyway, and eventually, all at once, understanding will come via epiphany, likely at the oddest moment. Oh yes, use code tags next time you post source, it makes code much easier to read (I have modified your posts this time around (and added more general formatting, out of boredom and desire to abuse my powers)). » Post edited 2007-06-25, 04:08pm by relpats_eht.
- relpats_eht
|
||
|
Please login or register to post a reply.