Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

Store data in mySQL DataBase Problem

Aloittaja Mr. Pedram, kesäkuu 01, 2014, 02:10:05 AP

« edellinen - seuraava »

Mr. Pedram

Hey there,
i trying to save data to mysql but got an error, here is my code:

<?php

global $modSettings$smcFunc;

$au $_REQUEST['au'];
$refID $_REQUEST['refID'];
echo 'au: ' $au;
echo '<br />';
echo 'refID: ' $refID;


$smcFunc['db_insert']('replace',
'{db_prefix}zarinpal',
array('refid' => 'string''au' => 'string'),
array($refID$au),
array('refid''au')
); //END smcFunc

?>


it will echo my request but can't store data. i know something is wrong, but this my second time that i working with SMF database structure.

here is the error:

LainaaFatal error: Function name must be a string in /homepages/5/d394578306/htdocs/Site/zarinpal/verify.php on line 18

Line 18 is:

$smcFunc['db_insert']('replace',

did i missed something to connect to SMF sql?
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

Arantor

If that's your entire script, it's guaranteed to fail since $smcFunc is not declared. I do not believe this is your full script.
Holder of controversial views, all of which my own.


Mr. Pedram

Lainaus käyttäjältä: ZombieCoder - kesäkuu 01, 2014, 11:43:14 AP
If that's your entire script, it's guaranteed to fail since $smcFunc is not declared. I do not believe this is your full script.

No this is just a sample. just trying to working with SMF database, and i wonder to know what i missed in this script for connecting to $smcFunc.
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

Arantor

Well, providing the actual script you're trying to use, in the situation you're trying to use it would probably help.

What you've provided will lead anyone to the wrong conclusion.
Holder of controversial views, all of which my own.


Mr. Pedram

You right, but it's a simple question
i got some data, echo working successfully, after echo (print) i trying to store this data to mysql. end :)

the question is, how can i store this data to mysql?
i created table, column, row and etc.. before, now time to store data.

anyone can help? :|
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

Arantor

Anyone could help if you answered the questions asked.

$smcFunc['db_insert'] giving you the error you're getting means $smcFunc isn't properly declared or in scope. But we'll never know all the time you insist on not providing the details.
Holder of controversial views, all of which my own.


Mr. Pedram

Sorry, i didn't understand the question, probably for my bad English!
details? Ok i explain more. but you know what, many time i did it, i mean explained the details but no one couldn't help/ anyway:

First, please read this topic

well, after user paid money, gateway will redirect to callback url,

LainaaFatal error: Function name must be a string in /homepages/5/d394578306/htdocs/Site/zarinpal/verify.php on line 18

verify.php is the callback file, echo will successfully work but in fact echo just a test for myself to sure gateway give me the refID correctly. the main issue isi want to store refID to database, that's all. is it clear?

you know what, this mod not my matter, i just want to learn how store data to database. for this mod and future mods..
for example, you REQUEST something, now how can i store it to DB?
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

Arantor

By using the $smcFunc['db_insert'] function that you haven't set up properly and won't give me the information to get you set up properly.
Holder of controversial views, all of which my own.


margarett

Sorry for stepping in, just my 0.02c ;)

If that file isn't really appended to SMF's "regular flow" (eg, you call it just with www.forum.com/verify.php), it will have no relation to any existing content, so $global $smcFunc is pointless.
You need to either:
* create an action,eg, index.php?action=verify, then calling your file through index.php or hooks (most likely the best option, especially if you're working on a MOD)
* include SSI.php, if your file runs totally independent
* have your file be loaded by an already existing Sources file (eg, require/require_once)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Arantor

There are all kinds of edge cases about that, which is why the subscriptions handler itself is outside the regular flow and loads SSI.php.

But this is why I asked for full details, though I should know by now that the OP will never provide all the details, only the details he thinks are relevant, which are often not entirely relevant. I should have ignored this thread, knowing this.
Holder of controversial views, all of which my own.


Mr. Pedram

Lainaus käyttäjältä: margarett - kesäkuu 02, 2014, 12:23:18 IP
Sorry for stepping in, just my 0.02c ;)

If that file isn't really appended to SMF's "regular flow" (eg, you call it just with www.forum.com/verify.php), it will have no relation to any existing content, so $global $smcFunc is pointless.
You need to either:
* create an action,eg, index.php?action=verify, then calling your file through index.php or hooks (most likely the best option, especially if you're working on a MOD)
* include SSI.php, if your file runs totally independent
* have your file be loaded by an already existing Sources file (eg, require/require_once)

Thank you @margarett for help and answer, yes the file is outside of SMF (eg: www.forum.com/zarinpal/verify.php) , hmmm .. now i get it why  $smcFunc didn't work, I'll try these steps and  then comeback to tell result.

Regard

---

@margarett, Problem solved successfully, finally data stored in database.
you are great, Thanks again.
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

Advertisement: