|
-
Aug 14th, 2004, 12:38 AM
#1
Thread Starter
Lively Member
[resolved] where clause
Hello all.
This is my first try at a WHERE clause with PHP.
What I need is the syntax for retrieving the correct record and printing it on the page.
Any help is appreciated.
Many thanks.
Code:
if (!$conn = new COM("ADODB.Connection")) exit("Unable to create an ADODB connection.");
$strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("..\db\users.mdb");
$conn->open($strConn);
$sql = "SELECT username FROM users WHERE 'username==$_POST[lstUser]'";
$rs = $conn->execute($sql);
// Need something here
// Print result here
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
Last edited by solitario; May 27th, 2005 at 02:55 PM.
-
Aug 14th, 2004, 03:32 AM
#2
I assume the reason you are posting here is becuase it doesn't work. Check your SQL statment, it should be:
Code:
SELECT username FROM users WHERE username='$_POST[lstUser]'
SQL is different from PHP, the equality operator is = not ==. You also had your quotes surrounding the entire 'username=$_POST[lstUser]', they just need tto surround the value.
-
Aug 16th, 2004, 07:01 AM
#3
Frenzied Member
Originally posted by visualAd
SQL is different from PHP, the equality operator is = not ==. You also had your quotes surrounding the entire 'username=$_POST[lstUser]', they just need tto surround the value.
You should really be seperating your values from your string better like this:
PHP Code:
$query = "SELECT x FROM y WHERE username='" . $_POST['lstUser'] . "'";
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|