what i am trying to do is permit the user to claim or reserve a spot with coord
my table has 4 feilds id ,continent,coord,nom id is primary key

what i am trying to do first i check if the coord already exist if they dont i update the database
id they do i want to echo whats in the feild nom for that particular entry

here is the code

  { 
    $db = mysql_connect('localhost', 'xxxxx', 'xxxxxx');  // connect to DB 
    mysql_select_db('xxxxx',$db);                  // select db

    // check if coord already exist
    $sql = "SELECT id FROM test WHERE coord='$coord'"; 
    $req = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());  

    // compting the results 
    $res = mysql_num_rows($req); 

    if($res!=0)  // if coord already exist display the content of the feild nom for that entry 
        { 
 $sql = "SELECT 'nom' FROM test WHERE coord='$coord'"; 
    $req = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); 
echo $req;

        } 
    else  // if coord dont exist make new data base entry
        {    
        $sql = "INSERT INTO test(id, nom, continent,coord) VALUES('','$nom','$continent','$coord')"; 
        mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());  

        // display msg to user
        echo 'GRATS  You Just Claimed IT.'; 

        } 
    mysql_close();  // close connection
    }

this is working well when i just echo a sorry msg
i know the problem is in the folowing 3 lines

          $sql = "SELECT 'nom' FROM test WHERE coord='$coord'"; 
        $req = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); 
    echo $req;

ty

What exactly does the error message say (the MySQL error/PHP error)

      $sql = "SELECT 'nom' FROM test WHERE coord='$coord'"; 
    $req = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); 
    $row=mysql_fetch_assoc($req);
echo $row['nom'];

thanks that did it :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.