...

View Full Version : Help displaying MySQL data



Zenzie
09-26-2004, 09:52 PM
Okay, I just don't know what is wrong. Here is the code:


<?php
include("config.php");
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
$cookie = $HTTP_COOKIE_VARS["starbits_username"];
$qry = mysql_query("SELECT bits FROM users WHERE username = $cookie") or die ("Could not get data because " . mysql_error());
$get_info = mysql_fetch_row($qry);
?>


It keeps coming out as this error:
Could not get data because Unknown column 'test' in 'where clause'

I have looked it over hundreds of times, could someone help me?

litebearer
09-26-2004, 10:43 PM
in your WHERE statement, try enclosing $cookie with single quotes.

Zenzie
09-28-2004, 01:19 AM
Now all I get is a blank screen.

Nightfire
09-28-2004, 01:26 AM
You would do. You're not printing anything out to the screen. You need to add something like

echo $get_info[0];

at the end of your script

Zenzie
09-28-2004, 02:58 AM
Ha ha ha :rolleyes: I'm so silly! Thanks for your help everyone!

Zenzie
09-28-2004, 03:10 AM
Now all it says is "Array"! I am so confused.

marek_mar
09-28-2004, 04:13 PM
to print out an array use print_r() (http://www.php.net/print_r).
To print out any variables in human-readable form use var_dump() (http://www.php.net/var_dump).

trib4lmaniac
09-28-2004, 09:05 PM
to print out an array use print_r() (http://www.php.net/print_r).
To print out any variables in human-readable form use var_dump() (http://www.php.net/var_dump).
print_r can print out anyyhing in human readable format. (I think.) According to php.net var_dump only show shows public properties of objects wheras print_r shows it all.

marek_mar
09-28-2004, 09:12 PM
Oh yes you are right. print_r shows the values and var_dump shows the types.
EDIT var_dump() showsd the type and the value and print_r() only the value.

Zenzie
10-03-2004, 01:41 AM
Now it displays

Resource id #5
Bits: 1

The bits is supposed to be 1500, and how do I get rid of Resource id #5?

Zenzie
10-03-2004, 06:46 PM
This is confusing :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum