PDA

View Full Version : can't get info from mysql


mr e
08-16-2002, 04:47 AM
ok i have a completely different page, nothing to do with vb, but here's what i have so far...


$DB = mysql_connect( "localhost", $DBUSER, $DBPASS ) or die("Could not connect to $DBNAME");

mysql_select_db( $DBNAME, $DB ) or die("Could not find database");

function view() {
$getshouts = mysql_query("SELECT * FROM shouts");
while(list($shouts) = mysql_fetch_array($getshouts, $DB)) {
echo $shouts[name];

}
...

and yes i DO have more in the view() funcion but i only listed what was neccessary, basically i can't get it to echo anything out, im only using the echo as a test to see if i can actually use the variables, i have tried quite a variety of ways but still can't figure out whats up...hope you can help :D

Dark_Wizard
08-16-2002, 11:29 AM
This:

echo $shouts[name];


should be this:

echo "$shouts[name]";

mr e
08-17-2002, 06:14 AM
this is what i have now, i've narrowed it down and i know it's something to do with the SELECT

$getshouts = mysql_query("SELECT name FROM shouts");
if (!$getshouts) {
echo("<P>Error performing query: " . mysql_error() . "</P>");
exit();
;}

echo "Your name is $name ! ";


and i have 4 entries all the same and it prints
Your name is ! Your name is ! Your name is ! Your name is !
so i dunno what the problem is, so hope someone can help :D

Dark_Wizard
08-17-2002, 11:33 AM
Change this:

$getshouts = mysql_query("SELECT name FROM shouts");
if (!$getshouts) {
echo("<P>Error performing query: " . mysql_error() . "</P>");
exit();
;}

echo "Your name is $name ! ";


to this:

$getshouts = mysql_query("SELECT name FROM shouts WHERE name=$name");
if (!$getshouts) {
echo("<P>Error performing query: " . mysql_error() . "</P>");
exit();
;}

echo "Your name is $name ! ";

Ajay
08-18-2002, 08:57 PM
$getshouts = mysql_query("SELECT * FROM shouts");


change that to
this should work:


$getshouts = "SELECT * FROM shouts";
mysql_query($getshouts)

or something similar

mr e
08-18-2002, 10:07 PM
ok i finally got it, thanks all :D