Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-24-2004, 04:27 PM   PM User | #1
Zenzie
New Coder

 
Join Date: Aug 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Zenzie is an unknown quantity at this point
Problem didplaying MySQL data

I am trying to make a script that will disply a users points (bits), but it always shows up as 1 when the number in the database is something else. Here is my code:
PHP 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(sparky_data)
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 print_r($qry);
echo 
"<br>Bits: <a href='bits.php'>$get_info</a>";
?>
Zenzie is offline   Reply With Quote
Old 10-24-2004, 04:36 PM   PM User | #2
KeZZeR
Regular Coder

 
Join Date: Oct 2004
Location: England
Posts: 282
Thanks: 0
Thanked 0 Times in 0 Posts
KeZZeR is an unknown quantity at this point
PHP Code:
echo "<br>Bits: <a href='bits.php'>$get_info</a>"
There's where your problem is at. It's better to do it like this:

PHP Code:
echo '<br>Bits: <a href="bits.php">' $get_info '</a>'
Now try that

EDIT: That's if you are trying to get the output from the $get_info variable to display between the anchor tags i hope. Otherwise i'm making myself look stupid
KeZZeR is offline   Reply With Quote
Old 10-24-2004, 04:37 PM   PM User | #3
As5a5sIn5
Regular Coder

 
Join Date: Apr 2004
Location: Philadelphia
Posts: 241
Thanks: 2
Thanked 5 Times in 5 Posts
As5a5sIn5 is an unknown quantity at this point
trying to echo the query? tsk tsk...lol
you have to add this ...

PHP 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(sparky_data)
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());  
while(
$row mysql_fetch_assoc($qry)){
$get_info $row[bits];
}
echo 
"<br>Bits: <a href='bits.php'>$get_info</a>";
?>
I'm pretty sure that will work...the $row[bits] part mite be wrong cuz idk what row you want to grab...good luck
As5a5sIn5 is offline   Reply With Quote
Old 10-24-2004, 05:05 PM   PM User | #4
Zenzie
New Coder

 
Join Date: Aug 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Zenzie is an unknown quantity at this point
Thanks! Let me see if this will work...
Zenzie is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:44 PM.


Advertisement
Log in to turn off these ads.