Apache

Moderators: None (Apply to moderate this forum)
Number of threads: 150
Number of posts: 335

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
SQL in PHP Posted by Dany on 6 Aug 2005 at 2:39 PM
Hello,
Can someone help me, I hope this is the right place for it.
I am trying to write sql queries in php and they are not working. I am pretty sure it's a quote double quote thing, which confuses me. can someone explain. I tried add/removeslashes() but they don't seem to help. would appreciate an example. this is what I am trying to write:
$query='update our_guests set username ='.$userid.' where guest ID = '.$id; (something like that anyways)
where $userid and $id are variables, and username is a field. I manage other SQL statements which are hardcoded so it must be a quote thing. Thanks!!
Report
I hope this is help ! Posted by satyadev on 25 Aug 2005 at 3:50 PM
Hi,
I think you have to write sql qury as following :

$query='update our_guests set username = $userid where guest ID = $id;
because $userid and $id is variable so no need to quote , when you are try to insert a hardcode string value then only you need to put quote.

I hope this is help.

With regards,
Satyadev Singh


Report
Re: I hope this is help ! Posted by weapon__x on 29 Mar 2006 at 7:05 PM
: $query='update our_guests set username = $userid where guest ID = $id;


this i think should read as:::>

: $query='update our_guests set username = $userid where guest ID = $id';


it happens...


baboy... baboy...

weaps

Report
Re: SQL in PHP Posted by luhnth on 10 Dec 2005 at 10:23 AM
Try this:

$query="UPDATE `our_guests` SET `username` ='".$userid."' WHERE `guest ID` = '".$id."'";


I was having trouble with that when I first started PHP and SQL. Some servers require you to do that. Oh yeah, next time, go to the SQL or the PHP message board, not the Apache board.


Best Regards,
CodeKing

Report
Re: SQL in PHP Posted by weapon__x on 29 Mar 2006 at 7:08 PM
or better yet try this:::>

$query="update our_guests set username ='" . $userid . "' where guest ID ='" . $id . "';";
that is, as i assume, if both fields are text and ID is not numeric.


baboy... baboy...

weaps

Report
Re: SQL in PHP Posted by dreams17 on 4 Apr 2007 at 4:17 AM
This message was edited by dreams17 at 2007-4-4 4:18:51


Hi,
i don know anything about php but then seeing ur query i was troubled.
why do u break ur head in all these?just my opinion






: Hello,
: Can someone help me, I hope this is the right place for it.
: I am trying to write sql queries in php and they are not working. I am pretty sure it's a quote double quote thing, which confuses me. can someone explain. I tried add/removeslashes() but they don't seem to help. would appreciate an example. this is what I am trying to write:
: $query='update our_guests set username ='.$userid.' where guest ID = '.$id; (something like that anyways)
: where $userid and $id are variables, and username is a field. I manage other SQL statements which are hardcoded so it must be a quote thing. Thanks!!
:








 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.