Results 1 to 3 of 3

Thread: [resolved] where clause

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Resolved [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.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    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'] . "'"
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width