-1

my code

$query = "SELECT `url` FROM `$drop` WHERE `vidname`= '$tier_two'";
$dave= mysql_query($query) or die(mysql_error());
    echo "<p>";
print $query;

im trying to the url feild to echo but im coming up with blanks

ids
  • 35
  • 1
  • 10

2 Answers2

0

you can do something like:

$result = mysqli_query($query);
$row = mysqli_fetch_array($result);
extract($row);

echo $url;

note: printing $query is printing your sql command.., for printing your query result, you can use my suggestion or @Companjo 's suggestion (ah, his post was deleted).. and (as @Phil's comment) the reason to use mysqli_* is because mysql_* is deprecated..

reference:
http://php.net/manual/en/mysqli-result.fetch-array.php
you might want to see the connection creation using mysqli here (if you decide to use mysqli_*): http://php.net/manual/en/mysqli.quickstart.connections.php

addition: mysql_ and mysqli_ don't differ much.. you'll realize it as you trying it..

0

You can try this:

$query = mysql_query("SELECT url FROM '$drop' WHERE vidname= '$tier_two'");  

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

  $url = $row["url"];   
  echo $url;

}
nickhar
  • 19,981
  • 12
  • 60
  • 73
  • PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in – ids Apr 08 '14 at 00:29
  • @ids That means your query failed and you didn't check `mysql_error`. Also it means you're using the woefully obsolete `mysql_query` interface. You need to upgrade to something more modern like PDO. – tadman Apr 08 '14 at 00:54
  • hi i was just using a rough draft PDO is next on my list thanks :D – ids Apr 08 '14 at 01:02