SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    ********* Addict DLG_1's Avatar
    Join Date
    Jun 2000
    Location
    Texas, USA
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $sql = "SELECT description FROM Promotions, Company, Lpromo WHERE Company.ID = Lpromo.company_ID AND Lpromo.promo_ID = Promotions.ID AND Company.ID = '$company_ID'";
    $sql_result = mysql_query($sql, $connection) or die ("Couldn't add the user");
    while ($row = mysql_fetch_array($sql_result)){
    $description = $row["description"];
    }
    //$description = $sql_result;


    this is my statement. when I use the while loop to return the value I don't get anything back. no error either.

    however when I use the commented out area $description = $sql_result; I get back "Resource id #5".

    I'm running the SELECT statement from my PHPadmin and it works fine, what gives?


    any help is greatly appreciated.


    Sam

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well for starters it looks like you are trying to grab description ? But from which table, you should probably try something like
    $sql = "SELECT description.Company as companydescription FROM Promotions, Company, Lpromo WHERE Company.ID = Lpromo.company_ID AND Lpromo.promo_ID = Promotions.ID AND Company.ID = '$company_ID'";

    But it is hard to tell what you are trying to get returned from the query, is there a description field in all the tables or just one?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    ********* Addict DLG_1's Avatar
    Join Date
    Jun 2000
    Location
    Texas, USA
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    turns out i was leaving some " in the end of the select statement which appears to be present in the code that i posted here because I had fixed the problem but hadn't uncommented out the other parts that would make it work. (ah... breathe!!!)


    Sam


Bookmarks

Posting Permissions

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