Please help Quick fix needed

Discussion in 'PHP' started by tommyda, Nov 11, 2007.

  1. #1
    When i try to run this script i get an error (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1)

    include'mysql.php';

    $result = mysql_query("SELECT * FROM cat_gambling")or die(mysql_error());
    $id = $row['id'];

    while($row = mysql_fetch_array( $result )) {

    $result2 = mysql_query("SELECT * FROM listings WHERE id = $id")or die(mysql_error());

    while($row2 = mysql_fetch_array( $result2 )) {

    echo $row['site'];
    };};

    Can anyone help me find a way to fix it please ?
     
    tommyda, Nov 11, 2007 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    hi
    i can help for $10 by paypal

    pm me
    I am online now


    Regards
    Alex
     
    kmap, Nov 11, 2007 IP
  3. tommyda

    tommyda Guest

    Messages:
    133
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    the purpose of the script is to get all id's (int) from table cat_gambling

    Then use the id's to grab information from the listings table

    eventually i will display the info in seperate tables using (while) function
     
    tommyda, Nov 11, 2007 IP
  4. tommyda

    tommyda Guest

    Messages:
    133
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the offer but i would rather work it out myself or go to phpfreaks forum
     
    tommyda, Nov 11, 2007 IP
  5. tommyda

    tommyda Guest

    Messages:
    133
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Fixed it myself using tizag.com

    // Get all the data from the "example" table
    $result = mysql_query("SELECT * FROM cat_gambling")or die(mysql_error());

    // keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result )) {
    $id = $row['poker'];
    $result2 = mysql_query("SELECT * FROM listings WHERE id = $id")or die(mysql_error());
    $row2 = mysql_fetch_array($result2) or die(mysql_error());
    echo $row2['site'];
    };
     
    tommyda, Nov 11, 2007 IP