PHP Script Not Writing Bankfee To Database


 
Thread Tools Search this Thread
Top Forums Programming PHP Script Not Writing Bankfee To Database
# 1  
Old 05-28-2009
PHP Script Not Writing Bankfee To Database

The attached file, credits.php, is part of our new (experimental) banking / credits system for this site.

I added a field bankfee in credits_transactions but it is not writing to the database (no PHP error).

Can someone take a look at the attached PHP file and see if they can find out why bankfee in the database table credits_transactions does not update from the initialized value of zero?

Code:
/* Neo: original
                $db->query_write("INSERT INTO " . TABLE_PREFIX . "credits_transactions (fromuserid, touserid, action, anonymous, comment, amount, timestamp, completed) VALUES (" . $vbulletin->userinfo['userid'] . ", " . $duser['userid'] . ", 'donate', " . $vbulletin->GPC['anonymous'] . ", '" . $db->escape_string(fetch_censored_text($vbulletin->GPC['comment'])) . "', " . $vbulletin->GPC['amount'] . ", " . TIMENOW . ", " . intval($notmoderated) . ")");
*/
                $db->query_write("INSERT INTO " . TABLE_PREFIX . "credits_transactions (fromuserid, touserid, action, anonymous, comment, amount, bankfee, timestamp, completed) VALUES (" . $vbulletin->userinfo['userid'] . ", " . $duser['userid'] . ", 'donate', " . $vbulletin->GPC['anonymous'] . ", '" . $db->escape_string(fetch_censored_text($vbulletin->GPC['comment'])) . "', " . $vbulletin->GPC['amount'] . ", " . $vbulletin->GPC['bankfee'] . ", " . TIMENOW . ", " . intval($notmoderated) . ")");

# 2  
Old 05-29-2009
Hi Neo,

If I traced correctly, the part you mentioned will be triggered by the donate form from the user CP. However, I fail to locate any form parameter matching the name "bankfee", where the code is trying to perform some sentry of the form data.

I suggest you print_r($vbulletin->GPC) after clean_array_gpc() and verify whether you still have the "bankfee" key and bear a non-zero value. My guess is that there is none. You can use error_log() to write the output to PHP log file (if configured).
# 3  
Old 05-29-2009
Thanks for replying. I agree with you.

FWIW,

The donate form is here.

https://www.unix.com/credits.php

And the donation processing is performed with:

https://www.unix.com/credits.php?do=donate

$bankfee is calculated:

Code:
$vbulletin->input->clean_array_gpc('p', array(
		'amount'	=> TYPE_UNUM,
		'fee'	=> TYPE_UNUM,
		'bankfee'	=> TYPE_UNUM,
		'recipient'	=> TYPE_NOHTML,
		'comment'	=> TYPE_NOHTML,
		'anonymous'	=> TYPE_BOOL
	));

	$amount = $transferred = $vbulletin->GPC['amount'];
	$donatefee = $vbulletin->GPC['amount'] * $vbulletin->options['credits_donatefee'];
	//$bankfee = $vbulletin->GPC['donatefee'];
	$bankfee = $donatefee;



The code in red was added my me ....

There will be no value (or maybe zero, initialized) for $bankfee immediately after clean_array_gpc() because $bankfee is calucated after clean_array_gpc().

So since $donatefee = $bankfee that means passing $vbulletin->GPC['bankfee'] to $db->query_write() does not work, but when I do:

//$bankfee = $vbulletin->GPC['donatefee'];

I get an error and the script fails.

What should I pass to $db->query_write() ?

-----Post Update-----

Hi cbkihong,

OK, it working fine now, thanks for the hints.

I replaced:

$vbulletin->GPC['bankfee'] in $db->query_write() with $bankfee

and it works fine Smilie

Easy fix, thanks for unfogging my weary brain!
# 4  
Old 05-29-2009
Quote:
Originally Posted by Neo
Easy fix, thanks for unfogging my weary brain!
Glad you figured it out. Thanks for confirming you indeed modified some additional code as I thought that variable should not have been passed from outside the server, obviously, for security reasons.

It's time for bed for me. Same for you! Smilie
# 5  
Old 05-29-2009
Quote:
Originally Posted by cbkihong
Glad you figured it out. Thanks for confirming you indeed modified some additional code as I thought that variable should not have been passed from outside the server, obviously, for security reasons.

It's time for bed for me. Same for you! Smilie
Oh! I forgot you are one hour ahead of me in HK.

Thanks again and goodnight. I will not be working on code much for the next 10 days, vacation time!

Our embryonic Bits Bank is now recording the bankfees in credits_transactions Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Several processes writing to an SQLite database at the same time

I have several bash scripts that write to an SQLite3 database at the same time. At some occasion the database returns: SQL error: database is locked. How would be the best way, to make a process to wait until the data base is 'free' again. I tried: sqlite3 test.db ".timeout 1000; update....."... (2 Replies)
Discussion started by: creamcheese
2 Replies

2. Programming

[PHP] asking how to make plain text database searching system

hi, i want to ask, how to make a plain text database (u need to call and search all the data manually) in PHP. i am going to apply it in UNIX os. anyone have any idea how to do it? most of the data only using mysql while i am forbid to do so. (2 Replies)
Discussion started by: grandios
2 Replies

3. Virtualization and Cloud Computing

Problems with PHP query to MySQL database

Hello all, I completed a website (it was code by php) and putted it to AWS, I install fedora instance in EC2 with the base is php and mysql. I putted all files of my website to folder /home/webuser/helloworld/htddocs and my database (mysql) to folder /var/lib/mysql/test ("test" is my... (2 Replies)
Discussion started by: hero132
2 Replies

4. Shell Programming and Scripting

Reading data from DataBase and Writing to a file

Hi All, Please help me in writing data to a file in one row. In database there is a column which contains large data which does not fit in the file in one row. The column contains list of paths. I want to write these paths to a file in one row. Please find the code below writes : ... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

5. Shell Programming and Scripting

writing script file for database

how to disable a constraint type of a field (present in diffrent tables) in the database unix a unix script file.. (3 Replies)
Discussion started by: shaksing
3 Replies

6. UNIX for Advanced & Expert Users

writing database tables into a file in unix

I want to collect the database tables(Ex: Emp,Sal,Bonus...etc) in a file & give this file at the command prompt, when prompted for the tables list at command prompt. How can i do that ? Ex:- Import jason/jason1 tables=emp,sal,bonus log=j1.log i want to change this into Ex:- Import... (3 Replies)
Discussion started by: dreams5617
3 Replies
Login or Register to Ask a Question