...

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



Zenzie
09-25-2004, 04: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:

<?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 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!

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

dniwebdesign
09-25-2004, 04: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.

hemebond
09-25-2004, 04: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum