Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Warning: Mysql_result(): Supplied Argument Is Not A Valid Mysql Result Resource In ..., This Is for My attack Script.
Feelay
post Feb 1 2008, 08:50 PM
Post #1


Kinda N00B
Group Icon

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
Go to the top of the page
 
+Quote Post
sparkx
post Feb 2 2008, 09:51 PM
Post #2


Sparkx
Group Icon

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'];
$row = mysql_fetch_array(mysql_query("SELECT * FROM database
WHERE User='$atkuser'") or die(mysql_error()));  
$EXP=$row['EXP'];
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.

Hope this helps at least a little,
Sparkx
Go to the top of the page
 
+Quote Post
Miles
post Feb 3 2008, 11:49 AM
Post #3


Advanced Member
Group Icon

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.
Go to the top of the page
 
+Quote Post
Feelay
post Feb 3 2008, 11:59 AM
Post #4


Kinda N00B
Group Icon

Group: Members
Posts: 230
Joined: 13-January 08
From: Sweden
Member No.: 27,579



I did that smile.gif Thanks smile.gif It is working now.. but as always, I am having a new problem tongue.gif
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
Go to the top of the page
 
+Quote Post
TavoxPeru
post Feb 8 2008, 05:43 AM
Post #5


Super Member
Group Icon

Group: [HOSTED]
Posts: 765
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



QUOTE(Feelay @ Feb 3 2008, 06:59 AM) *
I did that smile.gif Thanks smile.gif It is working now.. but as always, I am having a new problem tongue.gif
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,
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How To Make A Text Based Online Game Script ?(23)
  2. MySQL Realtime Replication(4)
  3. PHP: Writing A Generic Login And Register Script(14)
  4. Recover Tables From A MySQL .frm File(8)
  5. Bash Script To Display Your Ip(9)
  6. China To Nuke USA(53)
  7. [PHP + MySQL] Encrypting Data(11)
  8. Herbology: Uses And Dangers Of St. John's Wort(8)
  9. MySQL Output Database Question(18)
  10. Important: Basics Of Using PHP And MySQL(10)
  11. MySQL, Multiple Tables(24)
  12. PHP & MySQL: Displaying Content From A Given ID(6)
  13. Navcat For MySQL(9)
  14. Qupis : Free Cpanel Web Hosting (one Line Text Ad At Bottom)(10)
  15. Php Tutorial: Making A Shoutbox(12)
  1. Login System Using A Mysql Db(5)
  2. A Simple Register Script(3)
  3. Auto-click Script(7)
  4. Myspace Gold Script(2)
  5. Looking For Script(5)
  6. Mysql Database Entry By Excel Sheets(2)
  7. How To: Display A Members/user List.(3)
  8. Any Website Provide Free Host Mysql Host?(4)
  9. Mysql Multiple Tables(1)
  10. What You Need Before You Can Create A Text-based Game..(7)
  11. Automatic Typing Script(3)
  12. [fl]snow Effect(4)
  13. Mysql Overhead(3)


 



- Lo-Fi Version Time is now: 14th October 2008 - 01:07 PM