close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

PHP $ syntax problem

Thread began 9/07/2009 1:03 pm by colin282897 | Last modified 9/08/2009 9:50 am by Justin Nemeth | 2058 views | 5 replies |

colin282897

PHP $ syntax problem

I have a little bit of code that i need to take the date from my database and ad 1 year to it. So far I have found this code

<?php
$date = "binding goes in here????";
$newdate = strtotime ( '+1 year' , strtotime ( $date ) ) ;
$newdate = date ( 'Y-m-d' , $newdate );
echo $newdate;
?>

but when I try inserting the database binding into the "" in the first line it all goes wrong.

The binding in its simplest format looks like this <?php echo $row_renew_list['date']; ?>

So what is the syntax for inserting this into the ""

Sign in to reply to this post

anonymous

Colin,

Since you are already within PHP brackets, just ditch the extraneous PHP open and close with the echo command that you don't need.

Instead, make your code read:

php:
<?php

$date 
"$row_renew_list['date']";
$newdate strtotime '+1 year' strtotime $date ) ) ;
$newdate date 'Y-m-d' $newdate );
echo 
$newdate;
?>



Cheers,

Brian

Sign in to reply to this post

colin282897

That's what I thought but i get an error when I do this

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

Sign in to reply to this post

terry211640

a plea for help from the web expert

Hi, i am really sorry to highjack this thread but i can see from your previous posts that you are well knowledged with websites, php and all kinds of stuff, with this in mind can i please ask you to spend a couple of minuetes answering the probably silly questions that are causing me so many problems. people are viewing my thread but not posting a reply probably because they cant believe what i dont know :)

i would be grateful if you could help or at least point me in a direction where i can get the info myself

best wishes

terry


Hi to anyone who reads this. first of all i apologise in advance if the questions i will ask are stupid but i really dont know the answer and i was always told if you dont ask you dont know

i have been asked to produce a website for an estate agent ( real estate) i own super suite and use dreamweaver very sparingly over the last year or two.

i understand that i should use both site assist and data assist to create the finished site but i found myself confused at the first hurdle cos i have never done a dynamic site, so, the questions i would like to ask are :

1, do i need to build a seperate database to hold the information on the properties on the books of the estate agaent?
1a if so, which is better to build in access or something else? (i have access but have never used it however i have a subscription with the lovely people at linda.com so i could learn how to use it)
1b, if one has to be made do i build just the bare bones of it containing just the sections i want to feature or do i have to include all details of all the properties

1c if i have to include all the properties details, do i have to update the database each time there is a new property ,once everything is on line and up and running, or can i simply update using the web site which inturn updates the database instead of editing a database on my home machine then uploading another replacemnet data base?

2 the client ideally wants to have a site which mirrors one of the competitors sites which has a public viewing area and also a admin section to insert new details and ammend existing details etc - would i beable to create the same style with these programmes?

3 what is php and coldfusion? i hear the words but dont really know the difference, is it just similar to coke and pepsi as being brand names for the same product or something else?

3a do i need to own a copy of either programme inorder to complete my website. i do intend to upload all to a mainstrean domain hosting company?

3c which is better and by that i mean easier to use?

3d are they stuff that only servers use i dont have to worry apart from making sure the server i use supports the software?

those are my start off questions

i would really appreciate any help anyone can give an embarrassed rookie

Sign in to reply to this post

anonymous

Originally Said By: colin282897
  That's what I thought but i get an error when I do this

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING  



Hey Colin,

It may because of the quotes used... I have to fiddle with them because my mind goes gaga looking at code all day... one thing I have also done in the past is to store the recordset date to its own variable first like this:

php:
<?php 


$datetoget 
$row_renew_list['date'];

$date "$datetoget"
$newdate strtotime '+1 year' strtotime $date ) ) ; 
$newdate date 'Y-m-d' $newdate ); 
echo 
$newdate
?>



Try that and let me know.

Cheers,

Brian

Sign in to reply to this post

Justin Nemeth

There is no need to put " " around a variable name, you can just set it directly. So in your case, the code should be even a little simpler like this:

php:
<?php  
$date 
$row_renew_list['date'];  
$newdate strtotime '+1 year' strtotime $date ) ) ;  
$newdate date 'Y-m-d' $newdate );  
echo 
$newdate;  
?>

</span></span>

-justin

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...