Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   My code Problem (http://www.bvlist.com/showthread.php?t=1224)

al_ltoticmat 20th October 2008 17:12

My code Problem
 
I fixed it.
I want to auto pm to users who get this transfer bonus.

but it occurs this.
SQL 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 ' 2008-10-21 17:02:56, 'You receive money from ticc Value K\n', 0)' at line 1


Code:

$msg = sqlesc("You receive money from ".$CURUSER['username']." value ".$money." K");
                                @mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $receiver, ". get_date_time() .", $msg, 0)") or sqlerr(__FILE__, __LINE__);


djlee 20th October 2008 19:09

without seeing the entire code i cant help much but

go to your html output (i.e. view source in your browser)

and look for the hidden input



see what the value is .. it should be outputting the value of $user['id'] but from the error im guessing it is not .. either that or the code in userdetails uve added doesnt account for id being sent via post and is wanting the id var sent by GET .. as i said without seeing the mod you've installed as well as the code uve added i cant help


userid is 42 and value is 42.

This is my userdetail.php
al_ltoticmat 21st October 2008 07:17

1 Attachment(s)
value is correct.

Code:

  

djlee 21st October 2008 08:32

find
Code:


change to
Code:



al_ltoticmat 21st October 2008 08:39

oh thx you very much.

My page is running. Very thx you.
If I have another problems, can I ask you again?

djlee 21st October 2008 08:41

as long as u post in the forums and dont pm me .. u'll be waiting an extremely long time for replies via PM

al_ltoticmat 21st October 2008 08:42

if ($money > $user["seedbonus"])

I think this is wrong because I put the number just 1 it's say You don't have enough money but I have 13.4.

djlee 21st October 2008 08:48

replace the print statement that says u dont have enough money with
Code:

print("Money: ".$money."Allowed: ".$user['seedbonus']."");
see what it outputs

al_ltoticmat 21st October 2008 10:08

I see the errors.
Thank you

It should be
Code:

if ($money > $CURUSER["seedbonus"])
but
Code:

                        else
                        {
                                $receiver["seedbonus"] + $money;
                                $CURUSER['seedbonus'] - $money;
                        }

Users that I give didn't receive my money and I didn't lost my money.

djlee 21st October 2008 10:17

wheres the query that does it all

something like
Code:

@mysql_query("UPDATE users SET seedbonus = seedbonus + $money WHERE id=$receiver");
@mysql_query("UPDATE users SET seedbonus = seedbonus - $money WHERE id=".$CURUSER['id']);

After that you can remove the two lines in the else statement (the queries are off the top of my head you may need to correct them if they dont work)

al_ltoticmat 21st October 2008 10:32

You are the great.

It works perfect.

Thank you.

al_ltoticmat 21st October 2008 10:56

I fixed it.

but it occurs this.
SQL 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 ' 2008-10-21 17:02:56, 'You receive money from ticc Value K\n', 0)' at line 1

Code:

$msg = sqlesc("You receive money from ".$CURUSER['username']." value ".$money." K");
                                @mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $receiver, ". get_date_time() .", $msg, 0)") or sqlerr(__FILE__, __LINE__);


al_ltoticmat 22nd October 2008 10:40

I want to send a message to users who get a seedbonus.

The code above errors.

djlee 22nd October 2008 16:53

first of all u need to escape the date

change
Code:

get_date_time()
to
Code:

sqlesc(get_date_time())
secondly make sure u escape the message .. if you havenet already done this before using $msg in the query
change
Code:

$msg
to
Code:

".sqlesc($msg)."

al_ltoticmat 22nd October 2008 17:39

I don't know why
this problem haven't solve the another problem occurs.
Code:

if ($CURUSER["id"] != $user["id"])
{
        print("
Transfer Money\n");
        print("  ");
        if(isset($_POST["money"]) && ($money = 0+$_POST["money"]))
                        $receiver = $_GET["receiver"];
                        if ($money > $CURUSER["seedbonus"])
                        print("You don't have enough money");
                        else
                        {
                                $msg = sqlesc("You receive from".$CURUSER['username']." value ".$money." K");
                                @mysql_query("UPDATE users SET seedbonus = seedbonus + $money WHERE id=$receiver");
                                @mysql_query("UPDATE users SET seedbonus = seedbonus - $money WHERE id=".$CURUSER['id']);
                                @mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $receiver, ". sqlesc(get_date_time()) .", ".sqlesc($msg).", 0)");
                               

                        }
}


?>
I think maybe $receiver wrong.

The another problem is the user that I give seedbonus. He didn't receive but my seedbonus decreases. He didn't get a pm too.

djlee 23rd October 2008 00:27

try that (untested)
Code:

if ($CURUSER["id"] != $user["id"])
{
        print("
Transfer Money\n");
        print("
  
");
        if(isset($_POST["money"]) && ($money = 0+$_POST["money"]) != "")
                        $receiver = 0+$_POST["receiver"];
                        if ($money > $CURUSER["seedbonus"])
                        print("You don't have enough money");
                        else
                        {
                                $msg = "You receive from".$CURUSER['username']." value ".$money." K";
                                @mysql_query("UPDATE users SET seedbonus = seedbonus + $money WHERE id=$receiver");
                                @mysql_query("UPDATE users SET seedbonus = seedbonus - $money WHERE id=".$CURUSER['id']);
                                @mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $receiver, ". sqlesc(get_date_time()) .", ".sqlesc($msg).", 0)");
                               

                        }
}


?>

al_ltoticmat 23rd October 2008 09:35

Hey, you are the best I ever seen.

Very thank you.
Work perfect in every function.

You make me happy.


All times are GMT +2. The time now is 09:31.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.