fetching from mysql. what am i doing wrong?

Discussion in 'PHP' started by mmelen, Apr 29, 2008.

  1. #1
     <?php
    
    
    
     $con = mysql_connect("localhost","melennet_mmsearc","password");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
      mysql_select_db("melennet_mysearch", $con);
    
    
      $result=mysql_query("select * from search where word='"something"' limit 1");
      print $result;
    
    
      ?>
    Code (markup):
    I am getting an error.
    Any ideas?
     
    mmelen, Apr 29, 2008 IP
  2. CPURules

    CPURules Peon

    Messages:
    67
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
     
    <?php
    
    
    
     $con = mysql_connect("localhost","melennet_mmsearc","password");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
      mysql_select_db("melennet_mysearch", $con);
    
    
      $result=mysql_query("select * from search where word='\"something\"' limit 1");
      print $result;
    
    
      ?>
    
    PHP:
     
    CPURules, Apr 29, 2008 IP
  3. mmelen

    mmelen Well-Known Member

    Messages:
    1,526
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    105
    #3
    I now get: Resource id #2
     
    mmelen, Apr 29, 2008 IP
  4. mmelen

    mmelen Well-Known Member

    Messages:
    1,526
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    105
    #4
    solved.
    for next person who has this, this was my final solution:

    <?php
     $con = mysql_connect("localhost","melennet_mmsearc","asdf1234");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
      mysql_select_db("melennet_mysearch", $con);
    
    
      $result=mysql_query("select url from search where word='THEWORD' limit 1");
      $something = mysql_fetch_row($result);
      $something = $something[0];
      print $something;
      ?>
    Code (markup):
    probably not the most efficient thing in the world but it works :)
     
    mmelen, Apr 29, 2008 IP