Jump to content

[SOLVED] SELECT function (noob question)


matt82

Recommended Posts

this is probally a very noobish question

 

but i am haveing trouble getting this piece of code to work, when i run it the browser returns a blank white page.

 

 

 

<?php

$dbhost = 'localhost';

$dbuser = 'bonehead';

$dbpass = '********';

 

mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql')or die('Error, Connecting Failed');

 

$dbname = 'base2';

mysql_select_db($dbname);

 

 

$query = "SELECT name FROM table1 ORDER BY name DESC LIMIT 0 , 1";

 

 

$displ = mysql_fetch_array($query);

 

 

print $displ

?>

 

 

I was expecting it to return the value from the last row of the table from the column 'name' and save that value into the $displ value.

again sorry bout the noob question.

Link to comment
https://forums.phpfreaks.com/topic/119782-solved-select-function-noob-question/
Share on other sites

you aren't actually running the query.  you need to use mysql_query() on the query variable first, then pass THAT to mysql_fetch_array().  i've censored your password - in future, i'd consider blanking out your real password when posting code samples.

Yet another noob questions answered so well. Thanks a million

 

Oh and this is just a test app i am building to learn PHP will never see the internet hency why i wasnt worried about the password

But thankyou for your concern

I was able to get the whole thing working in 10 secs flat. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.