Re: Insert in database

From: Date: Mon, 29 Apr 2002 23:04:03 +0000
Subject: Re: Insert in database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-95292@lists.php.net to get a copy of this message
Just to point out how good the manual is :) php.net/echo "echo() is not actually a function (it is a language construct) so you are not required to use parentheses with it. In fact, if you want to pass more than one parameter to echo, you must not enclose the parameters within parentheses. It is not possible to use echo() in a variable function context, but you can use print() instead." instead of echo("Hi ",$_POST['fname'],"&nbsp;",$_POST['lname'],"Thank You For Registering !!!"); try echo "Hi ".$_POST['fname']."&nbsp;".$_POST['lname']."Thank You For Registering !!!"; Justin French --------------------- http://indent.com.au http://soundpimps.com --------------------- on 30/04/02 7:27 AM, Arpan De (dearpan1974@hotmail.com) wrote: > Hi Richard, > > Thank you very much for your prompt response. I incorporated the changes you > have suggested in my code but I am still getting exactly the same error !!! > What do I do now? I even commented the 3 lines related to database but when > I executed the code again, I got the same error but pointing to the echo("Hi > ...............") line. I am not understanding where am I erring !! Please > pin-point me as to where am I going wrong. > > Thanks once again, > > Regards, > > Arpan > > "Richard Baskett" <rick@baskettcase.com> wrote in message > news:B8F3050A.6360%rick@baskettcase.com... >> Well you don't have an curly braces anywhere in your code.. >> >> Try this: >> >> <?php >> >> If (($_POST['fname']=="") || ($_POST['lname']=="") >> { >> echo("Please Enter Information In All The Fields !!!"); } >> Else { >> $connectionString=odbc_connect("PHPInsert","sa",""); >> $query="INSERT INTO PHPUsers(FName,LName) VALUES >> ($_POST['fname'],$_POST['lname'])"; >> $exeQuery=odbc_do($connectionString,$query); >> odbc_close($connectionString); >> >> echo("Hi >> ",$_POST['fname'],"&nbsp;",$_POST['lname'],"Thank You >> For >> Registering !!!"); >> } >> >> ?> >> >> Rick >> >> "It is the mark of an educated mind to be able to entertain a thought >> without accepting it." - Aristotle >> >>> From: "Arpan De" <dearpan1974@hotmail.com> >>> Date: Tue, 30 Apr 2002 02:34:53 +0530 >>> To: php-general@lists.php.net >>> Subject: [PHP] Insert in database >>> >>> I have a simple HTML Form where a user has to enter his first & last > name >>> which will be inserted in a SQL Server database table. The PHP code > which >>> does the needful is as follows (I have created a DSN named PHPInsert >>> successfully as well): >>> >>> <?php >>> If(($_POST['fname']=="") || >>> ($_POST['lname']=="") >>> echo("Please Enter Information In All The Fields !!!"); >>> Else >>> $connectionString=odbc_connect("PHPInsert","sa",""); >>> $query="INSERT INTO PHPUsers(FName,LName) VALUES >>> ($_POST['fname'],$_POST['lname'])"; >>> $exeQuery=odbc_do($connectionString,$query); >>> odbc_close($connectionString); >>> >>> echo("Hi >>> ",$_POST['fname'],"&nbsp;",$_POST['lname'],"Thank You >>> For >>> Registering !!!"); >>> ?> >>> >>> The above code, when executed, throws the following error: >>> >>> Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, > expecting >>> T_STRING or T_VARIABLE or T_NUM_STRING >>> >>> pointing to the line where the variable $query is assigned the SQL >>> statement. What does the above error mean? Both the fields in the > database >>> are varchar datatype. The table also has an ID field which is an > IDENTITY >>> field auto-incrementing by 1. Where am I going wrong? >>> >>> Thanks, >>> >>> Arpan >>> >>> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> > >

« previous php.general (#95292) next »