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
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.

Link to comment
Share on other sites

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. :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.