Jump to content
MakeWebGames

Query error please can someone fix for me


Hitmanz
 Share

Recommended Posts

<?php

$housequery=1;

include_once "globals.php";

$TotalEXP = abs(@intval($ir['exp']/$ir['exp_needed']*100));

$BankMoney = ($ir['bankmoney'] == '-1') ? 'No Account!' : number_format($ir['bankmoney']);

if ( !$ir['married'] )

{

$marital="<font color='red'>No</font>";

}

else

{

$k=$db->query("SELECT username FROM users WHERE userid={$ir['married']}", $c);

$marital="<a href='viewuser.php?u={$ir['married']}' style='color:green;'>".mysql_result($k,0,0)."</a> ";

 

$marital.="[<a href='marriage.php'>Manage</a>]";

$mair=$db->query("SELECT u.*, h.* FROM users u LEFT JOIN houses h ON h.hWILL=u.maxwill WHERE userid={$ir['married']}",$c);

$ms=mysql_fetch_array($mair);

}

 

echo '<table width="55%" border="0" cellspacing="1" cellpadding="3" style="text-align:center;" class="table">

<tr>

<th colspan="3">General Info</th>

</tr>

<tr>

<td width="50%"><b>Name:</b> '.stripslashes($ir['username']).'</td>

<td width="50%"><b>Level:</b> '.number_format($ir['level']).'</td>

</tr>

<tr style="text-align:center;">

<td><b>EXP:</b> '.number_format($TotalEXP).'%</td>

<td><b>HP:</b> '.number_format($ir['hp']).'/'.number_format($ir['maxhp']).'</td>

</tr>

<tr>

<td><b>Money:</b> '.number_format($ir['money']).'</td>

<td><b>Crystals:</b> '.number_format($ir['crystals']).'</td>

</tr>

<tr>

<td><b>Crimes Passed:</b> '.number_format($ir['crimes']).'</td>

<td><b>Total Busts:</b> '.number_format($ir['busts']).'</td>

</tr>

<tr>

<td><b>Days Old:</b> '.number_format($ir['daysold']).'</td>

<td><b>Married:</b> '.stripslashes($marital).'</td>

</tr>

<tr>

<td><b>Bank Account:</b> '.$BankMoney.'</td>

<td><b>Property:</b> '.stripslashes($ir['hNAME']).'</td>

</tr>

</table>

<br />

';

 

$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ'];

$ir['strank']=get_rank($ir['strength'],'strength');

$ir['agirank']=get_rank($ir['agility'],'agility');

$ir['guarank']=get_rank($ir['guard'],'guard');

$ir['labrank']=get_rank($ir['labour'],'labour');

$ir['IQrank']=get_rank($ir['IQ'],'IQ');

$tsrank=get_rank($ts,'strength+agility+guard+labour+IQ');

$ir['strength']=number_format($ir['strength']);

$ir['agility']=number_format($ir['agility']);

$ir['guard']=number_format($ir['guard']);

$ir['labour']=number_format($ir['labour']);

$ir['IQ']=number_format($ir['IQ']);

$ts=number_format($ts);

echo'

<table width="55%" border="0" cellspacing="1" cellpadding="3" class="table" style="text-align:center;">

<tr>

<th colspan="3">Stats Info</th>

</tr>

<tr>

<th width="33%">Stat</th>

<th width="33%">Amount</th>

<th width="34%">Rank</th>

</tr>

<tr>

<td>Strength</td>

<td>'.number_format($ir['strength']).'</td>

<td>Rank: '.get_rank($ir['strength'], 'strength').'</td>

</tr>

<tr>

<td>Agility</td>

<td>'.number_format($ir['agility']).'</td>

<td>Rank: '.$ir['agirank'] = get_rank($ir['agility'], 'agility').'</td>

</tr>

<tr>

<td>Guard</td>

<td>'.number_format($ir['guard']).'</td>

<td>Rank: '.$ir['guarank'] = get_rank($ir['guard'], 'guard').'</td>

</tr>

<tr>

<td>Labour</td>

<td>'.number_format($ir['labour']).'</td>

<td>Rank: '.$ir['labrank'] = get_rank($ir['labour'], 'labour').'</td>

</tr>

<tr>

<td>IQ</td>

<td>'.number_format($ir['IQ']).'</td>

<td>Rank: '.$ir['IQrank'] = get_rank($ir['IQ'], 'IQ').'</td>

</tr>

</table>

<br>

<br>';

 

 

 

 

$_POST['pn_update'] = ( isset($_POST['pn_update']) )?strip_tags($db->escape($_POST['pn_update'])):'';

if ( !empty($_POST['pn_update']) ) {

if ( strlen($_POST['pn_update']) > 500 ) {

echo '<hr><span style="font-weight:bold;">You may only enter 500 or less characters here.</span>';

} else {

$db->query("UPDATE users SET user_notepad='{$_POST['pn_update']}' WHERE userid=$userid");

$ir['user_notepad']=stripslashes($_POST['pn_update']);

echo '<hr><span style="font-weight:bold;">Personal Notepad Updated!</span>';

}

}

echo "Your Personal Notepad:<form action='index.php' method='post'>

<textarea rows='10' cols='50' name='pn_update'>".htmlspecialchars($ir['user_notepad'])."</textarea><br />

<input type='submit' value='Update Notes' /></form>";

$h->endpage();

?>

 

 

 

says this: QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '999,999 AND us.userid != 2 AND u.user_level != 0' at line 1

Query was SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.strength > 9,999,999 AND us.userid != 2 AND u.user_level != 0

Link to comment
Share on other sites

Please put your code in [.code]CODE HERE[/.code] tags please (remove the .).

 

<?php
$housequery=1;
include_once "globals.php";

$TotalEXP = abs(@intval($ir['exp']/$ir['exp_needed']*100));
$BankMoney = ($ir['bankmoney'] == '-1') ? 'No Account!' : number_format($ir['bankmoney']);
if ( !$ir['married'] )

{

$marital="<font color='red'>No</font>";

}

else

{

$k=$db->query("SELECT username FROM users WHERE userid={$ir['married']}", $c);

$marital="<a href='viewuser.php?u={$ir['married']}' style='color:green;'>".mysql_result($k,0,0)."</a> ";



$marital.="[<a href='marriage.php'>Manage</a>]";
$mair=$db->query("SELECT u.*, h.* FROM users u LEFT JOIN houses h ON h.hWILL=u.maxwill WHERE userid={$ir['married']}",$c);
$ms=mysql_fetch_array($mair);
}



echo '<table width="55%" border="0" cellspacing="1" cellpadding="3" style="text-align:center;" class="table">
<tr>
<th colspan="3">General Info</th>
</tr>
<tr>
<td width="50%"><b>Name:</b> '.stripslashes($ir['username']).'</td>
<td width="50%"><b>Level:</b> '.number_format($ir['level']).'</td>
</tr>
<tr style="text-align:center;">
<td><b>EXP:</b> '.number_format($TotalEXP).'%</td>
<td><b>HP:</b> '.number_format($ir['hp']).'/'.number_format($ir['maxhp']).'</td>
</tr>
<tr>
<td><b>Money:</b> '.number_format($ir['money']).'</td>
<td><b>Crystals:</b> '.number_format($ir['crystals']).'</td>
</tr>
<tr>
<td><b>Crimes Passed:</b> '.number_format($ir['crimes']).'</td>
<td><b>Total Busts:</b> '.number_format($ir['busts']).'</td>
</tr>
<tr>
<td><b>Days Old:</b> '.number_format($ir['daysold']).'</td>
<td><b>Married:</b> '.stripslashes($marital).'</td>
</tr>
<tr>
<td><b>Bank Account:</b> '.$BankMoney.'</td>
<td><b>Property:</b> '.stripslashes($ir['hNAME']).'</td>
</tr>

</table>

<br />
';


$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ'];
$ir['strank']=get_rank($ir['strength'],'strength');
$ir['agirank']=get_rank($ir['agility'],'agility');
$ir['guarank']=get_rank($ir['guard'],'guard');
$ir['labrank']=get_rank($ir['labour'],'labour');
$ir['IQrank']=get_rank($ir['IQ'],'IQ');
$tsrank=get_rank($ts,'strength+agility+guard+labou r+IQ');
$ir['strength']=number_format($ir['strength']);
$ir['agility']=number_format($ir['agility']);
$ir['guard']=number_format($ir['guard']);
$ir['labour']=number_format($ir['labour']);
$ir['IQ']=number_format($ir['IQ']);
$ts=number_format($ts);
echo'
<table width="55%" border="0" cellspacing="1" cellpadding="3" class="table" style="text-align:center;">
<tr>
<th colspan="3">Stats Info</th>
</tr>
<tr>
<th width="33%">Stat</th>
<th width="33%">Amount</th>
<th width="34%">Rank</th>
</tr>
<tr>
<td>Strength</td>
<td>'.number_format($ir['strength']).'</td>
<td>Rank: '.get_rank(str_replace(',', '', $ir['strength']), 'strength').'</td>
</tr>
<tr>
<td>Agility</td>
<td>'.number_format($ir['agility']).'</td>
<td>Rank: '.$ir['agirank'] = get_rank(str_replace(',', '', $ir['agility']), 'agility').'</td>
</tr>
<tr>
<td>Guard</td>
<td>'.number_format($ir['guard']).'</td>
<td>Rank: '.$ir['guarank'] = get_rank(str_replace(',', '', $ir['guard']), 'guard').'</td>
</tr>
<tr>
<td>Labour</td>
<td>'.number_format($ir['labour']).'</td>
<td>Rank: '.$ir['labrank'] = get_rank(str_replace(',', '', $ir['labour']), 'labour').'</td>
</tr>
<tr>
<td>IQ</td>
<td>'.number_format($ir['IQ']).'</td>
<td>Rank: '.$ir['IQrank'] = get_rank(str_replace(',', '', $ir['IQ']), 'IQ').'</td>
</tr>
</table>
<br>
<br>';








$_POST['pn_update'] = ( isset($_POST['pn_update']) )?strip_tags($db->escape($_POST['pn_update'])):'';
if ( !empty($_POST['pn_update']) ) {
if ( strlen($_POST['pn_update']) > 500 ) {
echo '<hr><span style="font-weight:bold;">You may only enter 500 or less characters here.</span>';
} else {
$db->query("UPDATE users SET user_notepad='{$_POST['pn_update']}' WHERE userid=$userid");
$ir['user_notepad']=stripslashes($_POST['pn_update']);
echo '<hr><span style="font-weight:bold;">Personal Notepad Updated!</span>';
}
}
echo "Your Personal Notepad:<form action='index.php' method='post'>
<textarea rows='10' cols='50' name='pn_update'>".htmlspecialchars($ir['user_notepad'])."</textarea><br />
<input type='submit' value='Update Notes' /></form>";
$h->endpage();
?>

 

Your issue was that you were parsing/passing comma's thru to the get_rank function, and obviously, the get rank function does not type cast it back into a full digit.

But then again, looking back on the code, this is just plain horrible.

 

$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ'];
$ir['strank']=get_rank($ir['strength'],'strength');
$ir['agirank']=get_rank($ir['agility'],'agility');
$ir['guarank']=get_rank($ir['guard'],'guard');
$ir['labrank']=get_rank($ir['labour'],'labour');
$ir['IQrank']=get_rank($ir['IQ'],'IQ');
$tsrank=get_rank($ts,'strength+agility+guard+labou r+IQ');
$ir['strength']=number_format($ir['strength']);
$ir['agility']=number_format($ir['agility']);
$ir['guard']=number_format($ir['guard']);
$ir['labour']=number_format($ir['labour']);
$ir['IQ']=number_format($ir['IQ']);

 

EWWWW

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.

 Share

×
×
  • Create New...