webForumDet fria alternativet

if = o.s.v.

0 svar · 304 visningar · startad av SoulGod

SoulGodMedlem sedan aug. 20051 200 inlägg
#1

Jag kör just nu en slotmaskin på min hemsida som jag vill koppla till en databas,
som skall kunna utföra mindre ändringar i värden beroende på vinst.
Har även en databaskoppling till denna (MySQL),
där den just nu hämtar dessa två saker:

-----
Ändrar nu mitt inlägg, då jag löst några av frågorna..
Koden ser ut såhär nu:

<p>
  <?php require_once('Connections/MySQL.php'); ?>
  <?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_MySQL, $MySQL);
$query_get_userinfo = "SELECT * FROM users WHERE username = 'SoulGod'";
$get_userinfo = mysql_query($query_get_userinfo, $MySQL) or die(mysql_error());
$row_get_userinfo = mysql_fetch_assoc($get_userinfo);
$totalRows_get_userinfo = mysql_num_rows($get_userinfo);
// $get_update = "UPDATE users SET seedbonus=(seedbonus+50) WHERE username = 'SoulGod'";
// $sql_update = mysql_query($get_update, $MySQL) or die(mysql_error()); 
mysql_free_result($get_userinfo);
?>
</p>
<p><em><?php echo $row_get_userinfo['username']; ?></em> | <?php echo $row_get_userinfo['seedbonus']; ?><br>
</p>
<?
function slotnumber()
{
  srand(time());
    for ($i=0; $i < 3; $i++)
    {
      $random = (rand()%3);
      $slot[] = $random;
    }
?>
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="33%"><? print("<img src=\"$slot[0].png\">") ?></td>
    <td width="33%"><? print("<img src=\"$slot[1].png\">") ?></td>
    <td width="33%"><? print("<img src=\"$slot[2].png\">") ?></td>
  </tr>
	<tr>
	<td colspan="3">
	<?
// Rad 1 Likadant
    if($slot[0] == $slot[1] && $slot[0] == $slot[2])
    {
      print("Winner! 50 points ");
	  mysql_query("UPDATE users SET seedbonus=(seedbonus+50) WHERE username='". $row_get_userinfo['username'] ."'");
	  exit;
    }
}
?></td>
	</tr>
  <tr>
    <td><?
slotnumber();
?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td></td>
    <td><form method="POST" action="index.php">
      <input type="submit" value="Spin!" />
    </form></td>
    <td>&nbsp;</td>
  </tr>
</table>

Felet blir på mysql_query , att den inte lyckas läsa av nicket.
Dock fungerar det när man kör echo på nicket längre upp.

Varför kan den inte "läsa av" nicket när den ska införa det i databasen?
Om jag hårdkodar nicket in (skriver alltså nicket rakt ut) så funkar det?

140 ms totalt · 3 externa anrop · v20260731065814-full.0e50b1ef
137 ms — hämta forumlista (db)
0 ms — hämta statistik (cache)
125 ms — hämta tråd, inlägg och bilagor (db)