Click here to Skip to main content
15,914,071 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: How can I store an image to the database's field ? Pin
Marc Firth15-Jul-08 2:40
Marc Firth15-Jul-08 2:40 
GeneralRe: How can I store an image to the database's field ? Pin
Mohammad Dayyan3-Aug-08 10:21
Mohammad Dayyan3-Aug-08 10:21 
QuestionFunction return XML object.... unable to parse it to javascript Pin
Y_Kaushik25-Jun-08 19:42
Y_Kaushik25-Jun-08 19:42 
AnswerRe: Function return XML object.... unable to parse it to javascript Pin
Mohammad Dayyan3-Aug-08 10:46
Mohammad Dayyan3-Aug-08 10:46 
QuestionCan someone help me spot check this form code? Pin
bschm7825-Jun-08 19:27
bschm7825-Jun-08 19:27 
AnswerRe: Can someone help me spot check this form code? Pin
help as an alias25-Jun-08 20:14
help as an alias25-Jun-08 20:14 
GeneralRe: Can someone help me spot check this form code? Pin
bschm7826-Jun-08 3:11
bschm7826-Jun-08 3:11 
GeneralRe: Can someone help me spot check this form code? Pin
alex.barylski1-Jul-08 10:26
alex.barylski1-Jul-08 10:26 
Here is my corrected version:

1. You are/were including a full HTML document into an already existing defined HTML document. I removed the extraneous HTML from validation_functions.php4 incase they snuck in there by accident somehow.

2. You are testing a variable without the leading '$' which PHP uses to indicate a variable. Although it won't cause a parse error (syntactically it's acceptable) you won't get expected results because there is no constant named 'valid'

<br />
$valid = verifyAlphaNum($name);<br />
if(!valid) {<br />
$error_msg[] = "Name must be letters, spaces, dashes and ' only";<br />
}<br />


You should change these instances to:

<br />
$valid = verifyAlphaNum($name);<br />
if(!$valid) {<br />
$error_msg[] = "Name must be letters, spaces, dashes and ' only";<br />
}<br />


When I run your code I get the following error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /var/www/test.php on line 87

Here is a tip: Always include the error information like above when asking for help with source code, and always wrap the source code in a [code] bracket so it's nicely formatted. It saves people from having to copy/psate and run your code like I had to do.

Anyways, with that error message in hand I can quickly jump to line 87 in my editor and immediately spot the problem(s):

echo "<div align="center"><li>" .$err. "<li></li></li></div>";


You using double quotes for the HTML attribute when it's already wrapped in double quotes

Change that code to this:

echo '<div align="center"><li>'.$err.'</li></div>


Notice how I use double quotes for the HTML attribute and single quotes for the PHP string? That was intentional and should be considered a best practice. Why?

PHP parser supports interpolated strings, meaning you can use a PHP variable in a double quoted string, like this:

$test = 'Some Value';
echo "Hello world this is a variable: $test";


The above would output something like:

Hello world this is a variable: Some Value

While this might seem cool (and it is handy in some circumstances) it should be a practice avoided like the plague.

1. It can lead to difficult to find bugs as it's not very explicit.
2. You incur a performance hit because PHP tokenizer needs to process double quoted strings

By using single quoted strings instead od double inside PHP you save yourself from the above problems.

Use concatenation, like you already do:

echo 'This is a '.$test.' string';


Or you can also use the C style sprintf functions, like so:

echo sprintf('This is a string: %s', $test);


One more issue I've spotted:

if (!$error_msg ) && ($paypal == 'on')


Should be:

if (!$error_msg && $paypal == 'on')


Cheers Smile | :)

I'm finding the only constant in software development is change it self.

GeneralRe: Can someone help me spot check this form code? Pin
bschm783-Jul-08 6:21
bschm783-Jul-08 6:21 
Questionp0wned Pin
Christian Graus16-Jun-08 15:02
protectorChristian Graus16-Jun-08 15:02 
AnswerRe: p0wned Pin
Scott Dorman16-Jun-08 17:21
professionalScott Dorman16-Jun-08 17:21 
JokeRe: p0wned Pin
Leslie Sanford16-Jun-08 20:42
Leslie Sanford16-Jun-08 20:42 
QuestionFirst post !!! Pin
Christian Graus16-Jun-08 15:01
protectorChristian Graus16-Jun-08 15:01 
AnswerRe: First post !!! Pin
Scott Dorman16-Jun-08 17:20
professionalScott Dorman16-Jun-08 17:20 
AnswerRe: First post !!! Pin
Harvey Saayman17-Jun-08 1:19
Harvey Saayman17-Jun-08 1:19 
GeneralRe: First post !!! Pin
Paul Coldrey7-Oct-08 15:16
professionalPaul Coldrey7-Oct-08 15:16 
QuestionSQL Injection Prevention - How Good Are These Measures? Pin
nalorin11-Jun-08 7:55
nalorin11-Jun-08 7:55 
AnswerRe: SQL Injection Prevention - How Good Are These Measures? Pin
Bradml11-Jun-08 21:36
Bradml11-Jun-08 21:36 
GeneralRe: SQL Injection Prevention - How Good Are These Measures? Pin
Mohammad Dayyan11-Jun-08 22:57
Mohammad Dayyan11-Jun-08 22:57 
GeneralRe: SQL Injection Prevention - How Good Are These Measures? Pin
Chris Maunder12-Jun-08 0:20
cofounderChris Maunder12-Jun-08 0:20 
GeneralRe: SQL Injection Prevention - How Good Are These Measures? Pin
Bradml12-Jun-08 0:58
Bradml12-Jun-08 0:58 
GeneralRe: SQL Injection Prevention - How Good Are These Measures? Pin
Hesham Amin13-Jun-08 0:09
Hesham Amin13-Jun-08 0:09 
AnswerRe: SQL Injection Prevention - How Good Are These Measures? Pin
alex.barylski1-Jul-08 10:29
alex.barylski1-Jul-08 10:29 
QuestionSmarty Question !!! Pin
Mohammad Dayyan11-Jun-08 1:40
Mohammad Dayyan11-Jun-08 1:40 
AnswerRe: Smarty Question !!! Pin
Bradml11-Jun-08 21:37
Bradml11-Jun-08 21:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.