View Full Version : What's wrong with my code?

09-25-2004, 03:17 AM
I am trying to make a script that will display a persons points (bits) according to a username cookie, I've made a code, but I don't know what is wrong with it, it keeps coming up as errors. Here is the code:

// 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
or die ("Could not select database because ".mysql_error());
$cookie = $HTTP_COOKIE_VARS["starbits_username"];
$qry=mysql_query(SELECT username FROM users WHERE username=$cookie);
or die ("Could not get data because ".mysql_error());
$get_info = mysql_fetch_row($qry);

I would really like it if someone could tell me what is wrong with it. Thanks!

09-25-2004, 03:18 AM
It would also be nice to know how to get it to show up too. Like with an echo or print function.

09-25-2004, 03:42 AM
Can I ask you the next time please put your code in [ php ] tags... so that way it is highlighted and easier to read.

09-25-2004, 03:48 AM
$qry = mysql_query("SELECT username FROM users WHERE username = $cookie") or die ("Could not get data because " . mysql_error());Quotes added around query string and semi-colon removed from after call to mysql_query.