Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2004, 04:24 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Yes, you can do it like this:

echo "hey there $_SESSION[username]";

or this:

echo 'hey there '.$_SESSION['username'];

The first way is generally easier, but the second way uses less resources.

As Nik said in the reply I gave you....

"As always, read the manual!

http://www.php.net/types.string "

HTH!

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
 
Old November 12th, 2004, 11:11 PM
Registered User
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

just to be more specific the following script is working:

$email=$HTTP_POST_VARS["email"];
$pass=$HTTP_POST_VARS["passw"];
$type1=$HTTP_POST_VARS["type"];
$l="user.htm";
$l2="templogin.htm";

$Connection=odbc_connect("mp","mp","mp");
$in="insert into User values('$email','$pass','$type1')";
$run=odbc_do($Connection,$in);

but this one below, isn't...can someone tell me why cause i dont get it:

$cname =$_POST["name"];
  $telno=$_POST["telno"];
  $faxno=$_POST["fax"];
  $email=$_POST["email"];
  $Connection = odbc_connect("mp","mp","mp");
  $r="INSERT into Candidate (Tel_No, Name, Fax_No, Email)VALUES($telno,'$cname',$faxno,'$email') where Email=(SELECT Email FROM User where Email='$_SESSION["USER"]')";
  $query=odbc_do($Connection, $r);

here telno and faxno are numbers and not strings...as for the echo '$_SESSION["USERNAME"], that too isnt a problem - thats displaying...i really need this to work since my other pages are tied to this...so with this new info, can someone help me out now? mp

 
Old November 13th, 2004, 04:15 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

It's this part right here:

FROM User where Email='$_SESSION["USER"]')";

You see, you used the double quotes to enclose USER. But the string it's in is contained within double quotes. So when you use double quotes PHP thinks you're trying to end the string, but then there's just this USER thing right after the string, and it throws a parse error.

So do like this:

FROM User where Email='$_SESSION[USER]')";

Just get rid of the double quotes (only when inside a string; otherwise keep them).

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
 
Old November 15th, 2004, 05:08 AM
Registered User
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

okay, thanks that problem has been solved - now another problem has arisen...nothing to do with this thread tho...its an odbc_do probelm:

Warning: odbc_do(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query., SQL state S1000 in SQLExecDirect in d:\inetpub\wwwroot\LT\saveclient.php on line 15

the code is the same as above, although ive taken out the quotes as snib suggested.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
PHP Parse error: parse error, unexpected T_STRING geminient PHP How-To 4 August 18th, 2007 02:27 AM
T_VARIABLE goobywaj BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 March 28th, 2005 05:06 PM
Unexpected T_VARIABLE deamato BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 26th, 2005 08:11 PM
expecting `T_STRING' apek PHP How-To 9 January 29th, 2004 09:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.