/    Sign up×
Community /Pin to ProfileBookmark

PHP and updating

Hi All!

I have a script that allows me to keep track of client data.

I have a bunch of fields, but the two in concern are “startTime” “endTime”

I keep getting a canned error from my script thats tells me it is unable to run the query.

If I take these 2 lines out from the update, it works fine but does not update:
startTime = ‘$_REQUEST[starttime]’
endTime = ‘$_
REQUEST[endtime]’

Any ideas?

[code=php]
//fields
Start:
<input type=’text’ name=’starttime’ value='<?
if(empty($_REQUEST[starttime])) $_REQUEST[starttime] = “g:i”;
echo ($_REQUEST[starttime]);
?>’>

End
<input type=’text’ name=’endtime’ value='<?
if(empty($_REQUEST[endtime])) $_REQUEST[endtime] = “g:i”;
echo ($_REQUEST[endtime]);
?>’>

//To Update
$update_customer = “UPDATE user SET
startTime = ‘$_REQUEST[starttime]’
endTime = ‘$_REQUEST[endtime]’;
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 26.2006 — Not sure if this is the problem, but when interpolating array variable names within a quoted string (or any variable where it might not be clear to the parser where the variable name ends), use "complex notation":
[code=php]
$var = "This is {$array['index']} a test.";
[/code]
Copy linkTweet thisAlerts:
@comptech520authorFeb 26.2006 — My Appoligies NogDog.

I am not the php person quite yet, although I took a step and wrote a line of code from scratch today.

Could you please impliment your last post in my example?

Thanks
Copy linkTweet thisAlerts:
@NogDogFeb 26.2006 — It's just wrapping the array element variable with curly braces:
[code=php]
$update_customer = "UPDATE user SET startTime = '{$_REQUEST['starttime']}' endTime = '{$_REQUEST['endtime']}';
[/code]
×

Success!

Help @comptech520 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...