Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old May 29th, 2003, 09:10 PM
rcarr rcarr is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 34 rcarr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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

Reply With Quote
  #2  
Old May 29th, 2003, 09:58 PM
crisp crisp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Holland
Posts: 336 crisp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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 ;)

Reply With Quote
  #3  
Old May 29th, 2003, 10:12 PM
pfusch pfusch is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Victoria BC
Posts: 35 pfusch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL

Button names and superglobals. Jesus isn't happy.

Reply With Quote
  #4  
Old May 29th, 2003, 10:22 PM
rcarr rcarr is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 34 rcarr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.


Reply With Quote
  #5  
Old May 30th, 2003, 04:02 AM
DevilsEnigma DevilsEnigma is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Blacksburg,VA, USA
Posts: 30 DevilsEnigma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to DevilsEnigma Send a message via AIM to DevilsEnigma
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

Reply With Quote
  #6  
Old May 30th, 2003, 05:37 AM
pfusch pfusch is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Victoria BC
Posts: 35 pfusch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL


Quote:
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.


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...

Reply With Quote
  #7  
Old May 30th, 2003, 06:27 AM
crisp crisp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Holland
Posts: 336 crisp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
  #8  
Old May 30th, 2003, 06:43 AM
pfusch pfusch is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Victoria BC
Posts: 35 pfusch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: RE: Problem with Tutorial - Create dynamic sites with PHP & MySQL

Quote:
That's ok if you use PHP only for your site about your hamster,...


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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > Problem with Tutorial - Create dynamic sites with PHP & MySQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway