multi page form problem

I am trying to create a multi page application form using php and have ran into trouble with a syntax error when trying to insert a MySQL query for all the stored variables from the form. I get a syntax error in Dreamweaver from " . $_SESSION[‘name’] . ",

I also understand that these commands are no longer valid in versions 5.3 for PHP.

<?php //let's start our session, so we have access to stored data session_start(); //let's create the query $insert_query = 'insert into subscriptions ( name, email_address, membership_type terms_and_conditions, name_on_card, credit_card_number, credit_card_expiration_date ) values ( " . $_SESSION['name'] . ", " . $_SESSION['email_address'] . ", " . $_SESSION['membership_type'] . ", " . $_SESSION['terms_and_conditions'] . ", " . $_POST['name_on_card'] . ", " . $_POST['credit_card_number'] . ", " . $_POST['credit_card_expiration_date'] . " ); //let's run the query mysql_query($insert_query); ?>

You can’t mix single and double quotes like that. Since you started with single you should escape with single

So instead of this

[php]" . $_SESSION[‘name’] . "[/php]

It should be

[php]’ . $_SESSION[‘name’] . '[/php]

This will also be a syntax error:

[php]$_POST[‘credit_card_expiration_date’] . ")[/php]

It should be

[php]$_POST[‘credit_card_expiration_date’] . ‘)’[/php]

Oh excellent, thanks for the quick reply! Ill try it out shortly and see how it works.

works! thanks very much.

Sponsor our Newsletter | Privacy Policy | Terms of Service