Main Menu
collapse

Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 888
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]


Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

[solved] query in php block produce database error in block

Started by ag2ieric, February 19, 2010, 10:15:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ag2ieric

Hi,
i'm facing a problem that i couldnt succeed in solving by myself nor with google help ;) and i hope someone could help me here.

I want to make a simple mysql insert from a custom php block
i use
- a form
- with an input text
- at submit, i try to store the text in a table


Seems simple, but I face a double problem :

In dev env (WAMP+Win XP) :
when i use a db_query(...) function, it says no db select --> can't find how to select the db
when i use a direct sql insert function (mysql_query), it works

Now In final prod env (server)  :
direct sql saying "database error in code block' .
when i use a db_query(...) function, i got the same "database error in code block'.
--> it won't validate the new block.

I would really appreciate to have clues to solve the problem, a sample code or some tip to make this simple insert working ! thank in advance

EDIT:
I use this code in the php block that seems to work fine:

    global $boarddir;
    require_once($boarddir . '/../my_funcs.php');
    mycustomfunc();


My FIRST TRY : not working: (error = no database selected)
[code]
mycustomfunc()
{
   global $ID_MEMBER, $user_info, $db_connection,$db_prefix,$context;
   if (isset($_POST['question']) && !empty($_POST['question']))
   {
      $question = strip_tags($_POST['question']);

        $request = db_query("
            INSERT INTO {$db_prefix}faq
            VALUES (NULL, '".$question."', $ID_MEMBER),", __FILE__, __LINE__);
        if ($request) {
            echo "votre question
WIN XP SP3 - WAMP (PHP 5, MYSQL 5, APACHE 2, PMA 3.x)

ag2ieric

ok guys, seems i solved my problem

simply check "disable php validation" into the admin panel > SimplePortal > general settings
WIN XP SP3 - WAMP (PHP 5, MYSQL 5, APACHE 2, PMA 3.x)