Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2014
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Payout #2 Newspaper Not Updating Properly

    Hello again, I am a self taught programmer so veyr green at the thumbs. This script is meant to give the top rank newspaper gold coins and news saying the owner won, but for some reason the query is updating the 'to' in the news as blank and not the owners email. Nor is it updating the owners goldcoins. I dont think it is recognizing the owners uid or email. Was hoping someone could help me out?

    Code:
    $sql="SELECT rank, owner, name FROM newspaper_company ORDER BY rank DESC LIMIT 0,1";
                     $sql=mysql_query($sql);
                      if(@mysql_num_rows($sql)==0) {}
                     else {
                     while($temp=mysql_fetch_array($sql)) 
    		{
                    $uid = "SELECT uid, email FROM user_characters WHERE 'nickname' ='".$temp['owner']."'";
    		$uidd=mysql_fetch_array($uid); 
                    $sql = "UPDATE users_goldcoins SET goldcoins=goldcoins+100 WHERE 'uid'='".$uidd['uid']."'";
    		$sql = mysql_query($sql) or die(mysql_error());
    		$sql	= "INSERT INTO `news` (`to` , `news` , `timestamp`) VALUES ('".$uidd['email']."', '<br>Congratulations. You Have Won 100 B.D(s) For Finishing With The Top Ranked Newspaper ".$temp['name'].". ', '$time')";
    		$sql = mysql_query($sql) or die(mysql_error());
                     }}

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    It all comes down to the missing mysql_query calls. You cannot fetch from a string.
    I won't bother with a correction here, I've posted the joined insert in a previous thread. You should ensure the error reporting is enabled in the dev environment, preferably in the php.ini. Otherwise in line:
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    Will report the errors on screen. That would tell you things like mysql_fetch_array being provided with an incorrect datatype.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •