Sign in to follow this  
Followers 0
John117

proper formatting for this variable

11 posts in this topic

$sQuery = 'SELECT User_Name FROM Users WHERE User_Name="David"'

Replace David with variable $UserName

$sQuery = 'SELECT User_Name FROM Users WHERE User_Name= $UserName' -nope tried a few ways, none working

Anyone spot my mistake?

Share this post


Link to post
Share on other sites



$sQuery = 'SELECT User_Name FROM Users WHERE User_Name=' & $UserName


- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Thanks for the reply!

I tried that one earlier, doesnt seem to like it. This is an SQL query if that helps . . .

Share this post


Link to post
Share on other sites

Is it possibly an issue with quotation marks?

That is, considering the need for double ("") if you want the quotes to be passed as part of the string:

$UserName = ""David""

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

error looks right but does not include " around the userid . . . could be causing it . . . how would you insert " around it """ will not insert the text "

Share this post


Link to post
Share on other sites

when double quotes are needed just do:

$sQuery = 'SELECT User_Name FROM Users WHERE User_Name="' & $UserName & '"'

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Solved . . .

$sQuery = 'SELECT User_Name FROM Users WHERE User_Name=' & '"' & $UserName & '"'

Thanks for the help!

Share this post


Link to post
Share on other sites

$UserName = '"David"'
$sQuery = 'SELECT User_Name FROM Users WHERE User_Name=' & $UserName
MsgBox(0,"",$sQuery)

My mistake on the above entry, should have used single (') around the doubles(")


- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

$UserName = '"David"'
$sQuery = 'SELECT User_Name FROM Users WHERE User_Name=' & $UserName
MsgBox(0,"",$sQuery)

My mistake on the above entry, should have used single (') around the doubles(")

Thanks, works well :whistle:

Share this post


Link to post
Share on other sites

To avoid confusion with quotation marks I like to use StringFormat

$sQuery = StringFormat ( "SELECT User_Name FROM Users WHERE User_Name='%s'", $UserName)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0