Microsoft
Software
Hardware
Network
Question : Quoting array names in Associative Arrays in PHP in assignment and echo statements.
This is a bit of annoying problem. I am fixing up some sites that have statements like this:
while( $row=mysql_fetch_array($re
sult) )
{
$prty_id=$row[prty_id];
$prty_title=$row[prty_titl
e];
$prty_type=$row[prty_type]
;
$prty_bedrooms=$row[prty_b
edrooms];
$prty_baths=$row[prty_bath
s];
$prty_long_description=$ro
w[prty_lon
g_descript
ion];
$prty_sleeps=$row[prty_sle
eps];
$prty_floors=$row[prty_flo
ors];
$prty_price_per_night=$row
[prty_pric
e_per_nigh
t];
$prty_rates=$row[prty_rate
s];
$prty_amenities=$row[prty_
amenities]
;
$prty_close_to=$row[prty_c
lose_to];
$prty_pets=$row[prty_pets]
;
$prty_smoking=$row[prty_sm
oking];
$prty_handicapped=$row[prt
y_handicap
ped];
$prty_kid_friendly=$row[pr
ty_kid_fri
endly];
$prty_credit_cards=$row[pr
ty_credit_
cards];
$prty_rating=$row[prty_rat
ing];
$prty_hits_to_date=$row[pr
ty_hits_to
_date]+1;
$prty_calendar_id= $row[prty_calendar_id];
$id_ref_external = $row[prty_calendar_id];
$prty_display_id=$row[prty
_display_i
d];
}
and this:
echo "\n<a href=\"javascript:;\" onclick='return openWindow($prty_id,$i,$im
gAncho,$im
gAlto);' onmouseover=\"MM_swapImage
('mainpic'
,'','./gen
erar_image
n.php?imag
en=./image
s/properti
es/$row_ph
oto[pht_ph
oto]&a
ncho=300&a
mp;alto=20
0',1)\" onmouseout=\"\">";
On my hosting service server this doesn't cause any problems, I think because "notices" are turned off. On my home server (MAMP on OS X), I have notices and worse turned on. I am getting NOTICE errors because the argument is not quoted, which isn't a problem in the first set as I can quote those easily. In the second statement I've been resorting to something like this:
echo "\n<a href=\"javascript:;\" onclick='return openWindow($prty_id,$i,$im
gAncho,$im
gAlto);' onmouseover=\"MM_swapImage
('mainpic'
,'','./gen
erar_image
n.php?imag
en=./image
s/properti
es/".$row_
photo['pht
_photo']."
&ancho
=300&a
lto=200',1
)\" onmouseout=\"\">";
Just wondering if that is necessary and if there is a server setting that would ignore that. It seems to be working fine on my hosting service and I guess assumes that the argument should be/is quoted.
Kind of a pain to go through everything and add quotes.
Along those lines, is the a RegExp that would fix that generally?
i.e. Replace $array[string] with $array['string'] when it isn't in an echo statement and replace $array[string] with:
".$array['string'] ." when it is in an echo statement.
What is the best practice as far as that is concerned. Given that I am getting a warning I guess you should be using the quotes.
Answer : Quoting array names in Associative Arrays in PHP in assignment and echo statements.
The area under the curve would be the cumulative people impact over time. Unfortunately, there isn't a general relationship between people and time. (In the case of speed vs time... in a linear function, speed * time = distance.)
If population represented a drain of resources, you could consider the area under the curve as the total resources consumed by people...
If each unit of time were 'lifespan', the area under the curve would be 'corpses'.
Random Solutions
DFS on Windows Server 2003
Should I make a Drupal Theme from scratch?
With regards to correlated subqueries does anybody know what the logical query processing order?
breadcrumb trail in a dropdown box
asp.net: How to determine if a when a user login. is an Admin Account, * the menu is selected to show admin pages & reports.
Use .NET or SSIS to download Exhange email and process attachments
Importing a Word document To Fox Pro Tables
I need a free diagnostics program to confirm a bad hard drive that will not boot.
convert to valid DateTime
AJAX, JQUERY, server date timestamp