Hello. I started this post because i thought i needed to once again seek more information about errors i receive when running example scripts from my PHP/MySQL book, "Sams teach yourself PHP, MySQL, and Apache...". But, fortunately, i found the error and corrected it. but, i would like to follow through w/ this post anyway, so please allow me to continue.
yes, indeed i am still stuck at this book-- it's simply because i'm going through these script examples very thoroughly, writing notes, adding my own functions to them for experimentation, etc, in an attempt to assimilate the knowledge of how to write code for many different apps so that i might be able to handle real-world application to real-world script issues-- based on the situations presented in the example project scripts.
The examples in this book revisit in different ways, many of what must be some of the author's favorite techniques for handling problems. For example, in the case of a POST data <form> , to handle the submission of an empty form by the user, the script predictably will have the following test:
if ($_POST['fieldname'] == "") {
header("Location: filename.php");
OR, also qute commonly, essentially the inverse using "!=" as in:
if ($_POST[op] != "hidden_form_value") { print "<p><form> some form for user input, because the hidden value 'op' was NULL the first time around</form></p>";
the header("location: filename.php"); which as used in the samples in this book, always reload the same page (so, filename.php is the name of the file containing the header function), is an expression over which i have labored to find a reason why the author has chosen this method at all, as it quite often produces the error:
Warning: Cannot modify header information
some of you, Drakla, Logan, Laserlight, Thorpe, and Halojoy, should recall those struggles. one positive thing that has come of this is that Logan taught me to uses single quotes, as in
$_POST['textfield']
, instead of the book's
$_POST[textfield]
, which yeilds a PHP Parser notice "Use of undefined constant ... assumed ...", so now my output isn't littered w/ those notices! i'm very glad i've leard that. thank you, logan!
(side note to self: i need also to find a more reliable way to handle the passing of an empty form!)
I'm glad that my current examination of this Address Book script shows that it seems to function okay w/out any hair-pulling (but, actually, not w/out some modifications, such as the
$_POST['']
mentioned above. i do have a question regarding some of code.
two things:
one of the SELECT statements is as follows:
$get_list = "select id, concat_ws(', ', l_name, f_name) as display_name
from master_name order by l_name, f_name";
i looked up concat_ws at MySQL.com documentation, but all i found were changelog reports, or info on concat(). by deduction, i assume it has something to do w/ concatenation, but could someone please help me w/ that?
and also, and i suspect that this also performs some type of concatenation function, the code is as follows:
$display_block .= "<li>$address $city $state $zipcode ($address_type)";
where the .= is used all through the script to let the $display_block "add up" text for the ultimate output of a long bit of dynamic information. i also had trouble finding a definition at php.net/manual
my guess is that it .= can be used anytime it is necessary to add something to an existing variable w/in the currently executed script. do i have that about right from my deductive reasoning?
thank you!
p.s. this thread started out w/ a title of "expecting T_STRING'...", because i was getting that error when i tried to change [code=php] $_POST[select_id] to $_POST['select_id'] [/code] which produced theT_STRING`error. i searched, but didn't find much immediately useful info about that either. in fact, it's one of the few listed at the PHP Manual's Parser Tokens list which does not have a reference in the table on that page.
(wipes brow...) phew.. why do my posts usually take sometimes hours to compile!? how i often wish i could be satisfied w/ concise! and i realize it doesn't make it easy to respond w/ help either. but, i know no other way to express myself, and i always try to cover everything the first time around, so i'm usually simultaneously writing notes and studying my code-- hence the passage of time. :bemused:
blah, blah....
thanks to all for reading.