Hi,
Here's the source code:
<?php
error_reporting(-1);
//defines the database information needed in order to link to the database
define ('DB_NAME', 'questions');
define ('DB_USER', 'root');
define ('DB_PASSWORD', '');
define ('DB_HOST', 'localhost');
//the actual link between PHP and MySQL below
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
//error just incase it doesn't work so I can tell what's wrong
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//This selects the database I want to use and links it via msq_connect
$db_selected = mysql_select_db(DB_NAME, $link);
//incase of an error
if (!$db_selected) {
die('Can\'t use ' . DB_NAME . ':'.mysql_error());
}
$query = "SELECT * FROM `questions_user` ORDER BY id DESC";
$result = mysql_query($query);
if (!mysql_query($value)) {
die('Cannot obtain $query!' . mysql_error());
}
if (mysql_num_rows == 0) {
echo 'There are no queries at this time!';
die;
}
while($data = mysql_fetch_row($result)){
echo $data;
}
mysql_close();
?>
When I load the page I get a "query was empty" error.
The DB name is questions
The DB table is questions_user
The DB fields are `ID` and `questions_field`
This is some of the first interactive things i've made combining mysql and php. I know the code is probably sloppy.
Thanks for helping me out,
Fisher
P.S. I'm trying to output the data from 'questions_user' to just a random spot on a webpage.