Jump to content

Failing to recive mysql data on some computers


Zoroaster

Recommended Posts

OK, I'm making a browser game. And I want to decide if the player should succeed or fail. On the first page it shows a flash animation and head to the next, there it should show what happend. So first I'm updating the mysql with

$sql91 = "UPDATE `members` SET `sfaeradio` = '$g' WHERE `username` LIKE '$username';";
mysql_query($sql91);

 

in the script below.

 

animation0.php

<?php
session_start();
if(!session_is_registered("username")) {
								 header("location:logg.php");
								 }

$radio = $_POST['sfae'];
$tall = rand(1, 100);
$username = $_SESSION['username'];
$mhost = "";
$musername = "";
$mpassword = "";
$db_name = "";
$tbl_name = "";

mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql1 = "SELECT * FROM `members` WHERE `username` LIKE '$username'";
$query = mysql_query($sql1);

while($row1 = mysql_fetch_array($query))
{
    $sfae = $row1['sfae'];
}

echo "<html>";
echo "<body background ='http://i32.tinypic.com/2isti5j.jpg'>";

if ($tall <= $sfae) {

if ($radio == 1) {

$g = 1;

echo "<table border='2' bgcolor='#F0D081' align='center'><td><object width='720' height='835'><param name='movie' value='sfae1.swf'><embed src='sfae2.swf' width='720' height='835'></embed></object></td></table>";

}
if ($radio == 2) {

echo "<table border='2' bgcolor='#F0D081' align='center'><td><object width='720' height='835'><param name='movie' value='sfae1.swf'><embed src='sfae2.swf' width='720' height='835'></embed></object></td></table>";
$g = 2;

}
if ($radio == 3) {

echo "<table border='2' bgcolor='#F0D081' align='center'><td><object width='720' height='835'><param name='movie' value='sfae1.swf'><embed src='sfae2.swf' width='720' height='835'></embed></object></td></table>";
$g = 3;

}
if ($radio == 4) {

echo "<table border='2' bgcolor='#F0D081' align='center'><td><object width='720' height='835'><param name='movie' value='sfae1.swf'><embed src='sfae2.swf' width='720' height='835'></embed></object></td></table>";
$g = 4;

}
if ($radio == 5) {

echo "<table border='2' bgcolor='#F0D081' align='center'><td><object width='720' height='835'><param name='movie' value='sfae1.swf'><embed src='sfae2.swf' width='720' height='835'></embed></object></td></table>";
$g = 5;

}
}
else {

$g = 6;

echo "<table border='2' bgcolor='#F0D081' align='center'><td><object width='720' height='835'><param name='movie' value='sfae1.swf'><embed src='sfae1.swf' width='720' height='835'></embed></object></td></table>";
}

mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

echo "</body>";
echo "</html>";
$time = date("U");

$sql91 = "UPDATE `members` SET `sfaeradio` = '$g' WHERE `username` LIKE '$username';";
mysql_query($sql91);

$sql9 = "UPDATE `members` SET `sfaetime` = '$time' WHERE `username` LIKE '$username';";
mysql_query($sql9);

if ($r == 1) {
header("location:sfae_check.php");
}

?>

 

Then on sfae_check.php it should receive the data from mysql with

 


$sql1 = "SELECT * FROM `members` WHERE `username` LIKE '$username'";
$query = mysql_query($sql1);

while($row1 = mysql_fetch_array($query))
{
    $sfae = $row1['sfae'];
$rank = $row1['Rank'];
$money = $row1['Money'];
$radio = $row1['sfaeradio'];
}

 

But, there's the problem, on some computers it won't receive it. I have tired on two different computers. On one of them it works, and on the other one it doesn't. Both with IE browsers, and same veson. And when it don't receive the information the value of $radio = 0, and it becomes a blank page.

 

Here is sfae_check.php, this is the page that should receive the data from the mysql.

<?php
session_start();


$username = $_SESSION['username'];
$mhost = "";
$musername = "";
$mpassword = "";
$db_name = "";
$tbl_name = "";

mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql1 = "SELECT * FROM `members` WHERE `username` LIKE '$username'";
$query = mysql_query($sql1);

$timeonline = date("U");

$sql23 = "UPDATE `members` SET `online` = '$timeonline' WHERE `username` LIKE '$username';";
mysql_query($sql23);

while($row1 = mysql_fetch_array($query))
{
    $sfae = $row1['sfae'];
$rank = $row1['Rank'];
$money = $row1['Money'];
$radio = $row1['sfaeradio'];
}

if ($radio < 6) {

$sfaefull = $sfae + $radio;
mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

if ($sfae <= 50)
{
$sql2 = "UPDATE `members` SET `sfae` = '$sfaefull' WHERE `username` LIKE '$username';";
mysql_query($sql2);
}

if ($radio == 1) {


$earn1 = rand(33, 120);
$earn1full = $earn1 + $money;
echo "<html><body background='http://i32.tinypic.com/2isti5j.jpg'><table border='2' bgcolor='#F0D081' align='center'><td><center>";
echo "You found a rat and beat it heavly up. You took the skin and sold it for <b>" . $earn1 . "</b>";
echo "</center></td></table></body></html>";
mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql3 = "UPDATE `members` SET `Money` = '$earn1full' WHERE `username` LIKE '$username';";
mysql_query($sql3);
}

if ($radio == 2) {


$earn2 = rand(120, 320);
$earn2full = $earn2 + $money;
echo "<html><body background='http://i32.tinypic.com/2isti5j.jpg'><table border='2' bgcolor='#F0D081' align='center'><td><center>";
echo "You beat up a homeless, took him as a slave and sold him for <b>" . $earn2 . "</b>";
echo "</center></td></table></body></html>";
mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql4 = "UPDATE `members` SET `Money` = '$earn2full' WHERE `username` LIKE '$username';";
mysql_query($sql4);
}

if ($radio == 3) {


$earn3 = rand(287, 670);
$earn3full = $earn3 + $money;
echo "<html><body background='http://i32.tinypic.com/2isti5j.jpg'><table border='2' bgcolor='#F0D081' align='center'><td><center>";
echo "You found a guy that looked powerfull. Hit him hard in the balls and knock him down. You took his money and earned <b>" . $earn3 . "</b>";
echo "</center></td></table></body></html>";
mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql5 = "UPDATE `members` SET `Money` = '$earn3full' WHERE `username` LIKE '$username';";
mysql_query($sql5);
}

if ($radio == 4) {


$earn4 = rand(800, 1200);
$earn4full = $earn4 + $money;
echo "<html><body background='http://i32.tinypic.com/2isti5j.jpg'><table border='2' bgcolor='#F0D081' align='center'><td><center>";
echo "You fould a little mutant in the mountain and killed it, and took all it's items. You earned <b>" . $earn4 . "</b>";
echo "</center></table></td></body></html>";
mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql6 = "UPDATE `members` SET `Money` = '$earn4full' WHERE `username` LIKE '$username';";
mysql_query($sql6);
}

if ($radio == 5) {


$earn5 = rand(1000, 2000);
$earn5full = $earn5 + $money;
echo "<html><body background='http://i32.tinypic.com/2isti5j.jpg'><table border='2' bgcolor='#F0D081' align='center'><td><center>";
echo "You killed a gigantic mutant, and got the reward of <b>" . $earn5 . "</b>";
echo "</center></td></table></body></html>";
mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql7 = "UPDATE `members` SET `Money` = '$earn5full' WHERE `username` LIKE '$username';";
mysql_query($sql7);
}

$rankfull = $rank + $radio;

mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql8 = "UPDATE `members` SET `Rank` = '$rankfull' WHERE `username` LIKE '$username';";
mysql_query($sql8);

}


if ($radio == 6) {
$sfaefull = $radio;
$sfaehalv = $sfaefull / 2;
$sfaetot = $sfaehalv + $sfae;
mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

if ($sfae <= 50){
$sql2 = "UPDATE `members` SET `sfae` = '$sfaetot' WHERE `username` LIKE '$username';";
mysql_query($sql2);


echo "<html><body background='http://i32.tinypic.com/2isti5j.jpg'><table border='2' bgcolor='#F0D081' align='center'><td><center>";
echo "Nothing interesting happend.";
echo "</center></td></table></body></html>";

$rankfull1 = $radio / 2;
$rankfull2 =  $rank + $rankfull1;
mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql9 = "UPDATE `members` SET `Rank` = '$rankfull2' WHERE `username` LIKE '$username';";
mysql_query($sql9);

}
}
$time = date("U");

mysql_connect($mhost, $musername, $mpassword) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$sql92 = "UPDATE `members` SET `sfaeradio` = '0' WHERE `username` LIKE '$username';";
mysql_query($sql92);


?>

 

There are other players getting just a blank page too.

 

So could anyone please tell me what to do?

 

If you want to see what I'm trying to make could you visit http://www.worldinruins.net just make a account. And click on "Search for an enemy" on the scroller on the right.

Link to comment
Share on other sites

OK, this is probably not what you want to hear, but you need to consider that from the very first code you shared, this script is destined to break. You can't update based on username LIKE anything. Sooner of later you are going to have a username like "name", and when he goes to the script that updates the database, your user's with names like "nameguy", "nameboy", "namegirl" are all going to be updated. When I saw this code, I knew it wasn't worth going further.

 

This is the bad code:

$sql91 = "UPDATE `members` SET `sfaeradio` = '$g' WHERE `username` LIKE '$username';";
mysql_query($sql91);

 

Start over.

Link to comment
Share on other sites

OK, this is probably not what you want to hear, but you need to consider that from the very first code you shared, this script is destined to break. You can't update based on username LIKE anything. Sooner of later you are going to have a username like "name", and when he goes to the script that updates the database, your user's with names like "nameguy", "nameboy", "namegirl" are all going to be updated. When I saw this code, I knew it wasn't worth going further.

 

This is the bad code:

$sql91 = "UPDATE `members` SET `sfaeradio` = '$g' WHERE `username` LIKE '$username';";
mysql_query($sql91);

 

Start over.

There are no % wildcards so that query wouldn't match things like you stated..

Link to comment
Share on other sites

OK, this is probably not what you want to hear, but you need to consider that from the very first code you shared, this script is destined to break. You can't update based on username LIKE anything. Sooner of later you are going to have a username like "name", and when he goes to the script that updates the database, your user's with names like "nameguy", "nameboy", "namegirl" are all going to be updated. When I saw this code, I knew it wasn't worth going further.

 

This is the bad code:

$sql91 = "UPDATE `members` SET `sfaeradio` = '$g' WHERE `username` LIKE '$username';";
mysql_query($sql91);

 

Start over.

There are no % wildcards so that query wouldn't match things like you stated..

 

That was my first idea to. I consulted the manual but they only talk about the different possible pattern's they never actually say what LIKE does when no pattern's are provided.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.