Jump to content
MakeWebGames

can some one please help


skizzy

Recommended Posts

im currently working on a new game and i can't seem to get this code to update a field in my db. can some please help me with this

<?php
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);

$gip=make_ip();

function make_ip(){
$inum1 = rand(0,255);
$inum2 = rand(0,255);
$inum3 = rand(0,255);
$inum4 = rand(0,255);
$ip = $inum1.'.'.$inum2.'.'.$inum3.'.'.$inum4;
return $ip;	
}

echo "Ip set to"; echo make_ip();
mysql_query("UPDATE users set Gameip=$gip WHERE userid=$userid",$c);
?> 
Link to comment
Share on other sites

the original code ought to work... unless table is gameip (which i believe it is) and you are calling Gameip...

Tables are case sensitive in most cases...

also one minor detail...

echo "Ip set to"; echo make_ip();

you are echoing one fake IP that ought to be set off though you already had one...

so the correct line there ought to be...

echo "Ip set to ".$gip;
Link to comment
Share on other sites

well now i dont get any error but still wont update the db and the field GameIP is Correct

<?php
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON  u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);

$gip=make_ip();

function make_ip(){
	$inum1 = rand(0,255);
	$inum2 = rand(0,255);
	$inum3 = rand(0,255);
	$inum4 = rand(0,255);
	$ip = $inum1.'.'.$inum2.'.'.$inum3.'.'.$inum4;
	return $ip;    
}



echo "Ip set to ".$gip;
mysql_query("UPDATE users set GameIP=$gip WHERE userid=$userid",$c);
?> 
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...