|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem with Tutorial - Create dynamic sites with PHP & MySQL
I am brand new to PHP and MySQL, although I have DB experience with VFP and SQL Server. I am trying to go through the tutorials but I am sort of stuck on this one.
http://codewalkers.com/tutorials/9/11.html The tutorial indicates that I should see this URL: http://yourhost/input.php?first=Rick&last=Denver&nickname=Mike&email=j@xyz.com&salary=25000&submit=Enter+information Unfortunately I just see the basic URL: http://yourhost/input.php Here is the code I am executing. <HTML> <?php if($submit) { $db = mysql_connect("localhost", "username","password"); mysql_select_db("learndb",$db); $sql = "INSERT INTO personnel (firstname, lastname, nick, email, salary) VALUES ('$first', '$last', '$nickname','$email','$salary')"; $result = mysql_query($sql); echo "Thank you! Information entered.n"; } else { ?> <form method="get" action="input.php"> First name:<input type="Text" name="first"><br> Last name:<input type="Text" name="last"><br> Nick Name:<input type="Text" name="nickname"><br> E-mail:<input type="Text" name="email"><br> Salary:<input type="Text" name="salary"><br> <input type="Submit"name="submit" value=" Enter information"></form> <? } ?> </HTML> Any idea what I am doing wrong? The previous sections in this tutorial work fine. Thank you! Robert |
|
#2
|
|||
|
|||
|
RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL
This looks very bad; I think the main problem is in the HTML output itself. An html document should look (at least) like this:
<html> <head> <title>some title</title> </head> <body> html content goes here </body> </html> (note that for purists like me you should add a DTD and some character-encoding tag like a meta) as you don't have a body you actually don't have a document; it's surprising that your browser is actually showing something (IE right? ;) ) Furthermore I object to the absence of superglobals, and the use of name="submit" (which is a reserved method for javascript) and the use of if ($submit) that should give you at least a notice when using error_reporting(E_ALL) (which should be the default on any development machine) Not to mention that IE doesn't pass the value of the submit button if you use enter to submit a form. All in all my votes are for putting this tutorial into the trashcan ;) |
|
#3
|
|||
|
|||
|
RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL
Button names and superglobals. Jesus isn't happy.
|
|
#4
|
|||
|
|||
|
RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL
Thanks for the insight. I am glad this tutorial is bare bones though, as it does allow the reader to grasp the concepts pretty easily. This is "learning code," not "fully functional" code.
|
|
#5
|
|||
|
|||
|
RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL
try going to www.php.net and learning they are better of at the tutorials
|
|
#6
|
|||
|
|||
|
RE: RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL
Quote:
That's a valid argument, but by using something like autoglobals in the tutorial, the user is 'learning' to use them. That's not good. It's easy to not start using something like that. It's hard to stop if you learned that way. I learned php using <? tags to start code. I have recently moved to using <?php all the time, but it's VERY difficult now that I've been doing it the afformentioned way for so long... |
|
#7
|
|||
|
|||
|
RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL
programming was never meant to be easy, nor will it ever be.
We have a saying here, free translated: 'soft docters make stinking wounds'. Yes, you can learn to code the easy way by using all the newbie features PHP has built in such as magic_quotes, register_globals, the automatic parsing of variables in strings. But using those features you will never learn to write portable, safe and meantainable code. That's ok if you use PHP only for your site about your hamster, but if you want to do professional stuff it's better to learn the hard way from the start. |
|
#8
|
|||
|
|||
|
RE: RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL
Quote:
Hahahah!!! I haven't had a laugh that good in like an hour and a half. Good times. On the subject of writing safe, portable code, I am going to start a new thread, so as to not stray too much in this one. It will be called 'safe coding' or 'code naziism' or something. I am looking for some collaborative ideas. |
![]() |
| Viewing: Codewalkers Forums > Other > Tutorials > Problem with Tutorial - Create dynamic sites with PHP & MySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|