|
|
|
|
![]() ![]() |
Feb 1 2008, 08:50 PM
Post
#1
|
|
|
Kinda N00B Group: Members Posts: 230 Joined: 13-January 08 From: Sweden Member No.: 27,579 |
Hey. I am making a "Version 2.0" For my attack script, but I can't make it work.
This is the error I am gettin: Warning: mysql_result(): supplied argument is not a valid MySQL result resource in And here is the code: CODE $dbQueryHealth = mysql_query("SELECT temphealth FROM characters WHERE user =". $_POST['atkuser'].""); $currentHealth = mysql_result($dbQueryHealth, 0); $dbQueryExp = mysql_query("SELECT exp FROM characters WHERE user = ".$_POST['atkuser'].""); $currentExp = mysql_result($dbQueryExp, 0); I have checked the PHP Manual, but I did not find anything there :S Thanks For All you help //Feelay |
|
|
|
Feb 2 2008, 09:51 PM
Post
#2
|
|
|
Sparkx Group: [HOSTED] Posts: 355 Joined: 11-October 06 From: Dana Point, CA, USA Member No.: 16,496 |
It looks like your mysql_query is wrong. Correct me if I am wrong but I am pretty sure your use WHERE Column='$var' not WHERE Column=".$var." Also you seem to have a odd way of result. I usually do it quite differently but I am not sure what the major difference is.
Example CODE $atkuser=$_POST['atkuser']; After looking at your code a bit I realized that it seem very strange. I have never seen anyone $_Post a variable directly to a Mysql. First off it is EXTRAMLY insecure and secondly anyone that know PHP could hack it. My example above is also hack-able but you can solve that with a simple preg_replace or preg_match. I am also not quite sure why you have , 0) after your result.$row = mysql_fetch_array(mysql_query("SELECT * FROM database WHERE User='$atkuser'") or die(mysql_error())); $EXP=$row['EXP']; Hope this helps at least a little, Sparkx |
|
|
|
Feb 3 2008, 11:49 AM
Post
#3
|
|
|
Advanced Member Group: [HOSTED] Posts: 177 Joined: 25-December 07 Member No.: 27,129 |
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in [file] is caused by an sql query that isn't done correctly, usually. To fix it I suggest doing what will be the SQL query firstly in a variable then using mysql_query($sqlvariable), that should solve your problem.
|
|
|
|
Feb 3 2008, 11:59 AM
Post
#4
|
|
|
Kinda N00B Group: Members Posts: 230 Joined: 13-January 08 From: Sweden Member No.: 27,579 |
I did that
The value in the database is not updating :S here the code for the update, should'nt it work =? CODE $SeUs = $_SESSION['user'];
$PoUS = $_POST['atkuser']; mysql_query ("UPDATE characters SET temphealth =\"{$currentHealthYou}\" WHERE user =\"{$SeUs}\""); mysql_query ("UPDATE characters SET temphealth = \"{$currentHealthEnemy}\" WHERE user =\"{$PoUs}\""); This post has been edited by Feelay: Feb 3 2008, 12:01 PM |
|
|
|
Feb 8 2008, 05:43 AM
Post
#5
|
|
|
Super Member Group: [HOSTED] Posts: 765 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 |
I did that The value in the database is not updating :S here the code for the update, should'nt it work =? CODE $SeUs = $_SESSION['user']; $PoUS = $_POST['atkuser']; mysql_query ("UPDATE characters SET temphealth =\"{$currentHealthYou}\" WHERE user =\"{$SeUs}\""); mysql_query ("UPDATE characters SET temphealth = \"{$currentHealthEnemy}\" WHERE user =\"{$PoUs}\""); You can use the session variable directly in your code, instead of escaping your strings simply use a single quote ('), also, to prevent sql injections use the mysql_real_escape function with the data posted to your script. And personally i always attach a die() function with the mysql_error() function to every query i make to check if every thing works fine. Try the following: CODE <?php $PoUS = mysql_real_escape_string($_POST['atkuser']); mysql_query ("UPDATE characters SET temphealth='$currentHealthYou' WHERE user='" . $_SESSION['user'] ."'") or die(mysql_error() ); mysql_query ("UPDATE characters SET temphealth = '$currentHealthEnemy' WHERE user ='$PoUs'") or die(mysql_error()); ?> Best regards, |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 14th October 2008 - 01:07 PM |