Author Topic: MySQL database help  (Read 266 times)

0 Members and 1 Guest are viewing this topic.

Offline katarraTopic starter

  • Enthusiast
  • Posts: 95
    • View Profile
    • Katarra
MySQL database help
« on: March 03, 2010, 05:47:25 PM »
I'm having a problem with the result coming up as 0 so it just says I have "no energy left", which isn't the case.

Here's the part of the code that isn't working right. Any help would be AWESOME! Thanks!

Code: [Select]
<?php
function fish($username){
$data ""; $dbh=dbconnect() or die ('Fish error: ' mysql_error()."<br>");
mysql_select_db("katarra_game");
$result mysql_query("SELECT * FROM users WHERE username = '$username'");
if (mysql_num_rows($result) > 0$data stripslashes(mysql_result($result,0,$var));
mysql_close($dbh);
$data str_replace("&#38;#39;","'",$data);
return 
$data;}

$data $user;
$expgain 1;
$expgain2 2;

if (
$user->energy <= 0
{
echo "You have no energy left!" ;
exit;
}

Offline mapleleaf

  • Enthusiast
  • Posts: 237
    • View Profile
Re: MySQL database help
« Reply #1 on: March 03, 2010, 10:35:42 PM »
Have you echoed out $data to see what you get?

Offline katarraTopic starter

  • Enthusiast
  • Posts: 95
    • View Profile
    • Katarra
Re: MySQL database help
« Reply #2 on: March 04, 2010, 07:31:12 AM »
Yeah, it comes back as just a blank screen, so it's not pulling anything.

Online fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: MySQL database help
« Reply #3 on: March 04, 2010, 10:00:32 AM »
Yeah, it comes back as just a blank screen, so it's not pulling anything.
Blank screen = PHP error == wrong forum.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.