RE: [PHP] confused big time
| From: | Chris W. Parker | Date: | Wed, 07 Apr 2004 00:09:15 +0000 |
| Subject: | RE: [PHP] confused big time | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-182570@lists.php.net to get a copy of this message | ||
Chris W. Parker <>
on Tuesday, April 06, 2004 5:01 PM said:
let me expand both of my points in an attempt to be more verbose.
> 1. write readable queries.
> 2. always put single quotes around array keys. $array['key']
here is how i would write your query:
<?php
$sql = "
insert into $EventsTable
values(
NULL
, '{$_SESSION['add']['type]}'
, '{$_SESSION['add']['start_date']}'
, '{$_SESSION['add']['end_date']}'
, '{$_SESSION['add']['name']}'
, '{$_SESSION['add']['county']}'
, '{$_SESSION['add']['discription']}'
, '{$_SESSION['add']['StartingDay']}'
, '{$_SESSION['add']['StartingMonth']}'
, '{$_SESSION['add']['StartingYear']}'
, '{$_SESSION['add']['EndingDay']}'
, '{$_SESSION['add']['EndingMonth']}'
, '{$_SESSION['add']['EndingYear']}'";
$sql = "
insert into $GuestbookTable
values(
NULL
, '{$_SESSION['add']['date']}'
, '{$_SESSION['add']['name']}'
, '{$_SESSION['add']['email']}'
, '{$_SESSION['add']['website']}'
, '{$_SESSION['add']['referred']}'
, '{$_SESSION['add']['comments']}')";
hth,
chris.