www.webdeveloper.com
Results 1 to 3 of 3

Thread: Help!! Simple mysql select with variable

  1. #1
    Join Date
    May 2011
    Location
    Central Florida
    Posts
    5

    Exclamation Help!! Simple mysql select with variable

    I have a variable $BrokerID that i'm trying to place into the query for Mysql. I think the synax is wrong it will not work. YET when I replace = $BrokerID with = \'50786\' it works fine. I think my synax is wrong. I'm new to php and mysql help would be highly appreciated.

    Thanks in advance!!

    $BrokerID = 50786;
    $query = "SELECT * FROM `Properties` WHERE `Sold Office ID` = $BrokerID LIMIT 0, 1 ";

  2. #2
    Join Date
    Jul 2010
    Location
    /ramdisk/
    Posts
    865
    Help!! Simple mysql select with variable
    PHP Code:
    <?php

    mysql_connect
    ("host","user","pass");
    $variable 123;
    $SQLResource mysql_query("SELECT $variable");

    if(
    mysql_num_rows($SQLResource) {
      echo 
    "simple " implode(''.mysql_fetch_array($SQLResource));
    } else {
      echo 
    mysql_errno() ?: mysql_error(); /* <<<<--------- USE THIS LINE */
    }

    ?>

  3. #3
    Join Date
    May 2011
    Location
    Central Florida
    Posts
    5

    Thanks!!

    fixed it. thanks alot!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles