1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unmaintained How to read and write into the database (with a page) 1.0

I'll teach you how to read and write to the database using XenForo.

  1. Fuhrmann

    Fuhrmann Well-Known Member

    Fuhrmann submitted a new resource:

    How to read and write into the database (with a page) (version 1.0) - I'll teach you how to read and write to the database using XenForo.

    Read more about this resource...
     
  2. Fuhrmann

    Fuhrmann Well-Known Member

    Fuhrmann updated How to read and write into the database (with a page) with a new update entry:

    Part 2

    Read the rest of this update entry...
     
  3. 0xym0r0n

    0xym0r0n Well-Known Member

    On step 10 you have to add
    PHP:
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}/>
    Otherwise you get a security error.
    IDK if there's another work around but I just searched the error and that's the line that seems to be suggested to solve the security error.

    Great tutorial :)
     
    starwars, Thomas.B, Sebastian and 3 others like this.
  4. I managed to get this to write, however when it tries to read it seems as if it's trying to add my subdomain on it as well. I changed all the Simpletexts to my addon name "mcstore".

    "dev" is my subdomain. Everything is hosted locally.

    Here is my error.
    Code:
    The following error occurred:
     
    Mysqli prepare error: Table 'dev.xf_mcstore_text' doesn't exist
    Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
    Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
    Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
    Zend_Db_Adapter_Abstract->query() in XenForo/Model.php at line 218
    XenForo_Model->fetchAllKeyed() in mcstore/Model/mcstore.php at line 19
    mcstore_Model_mcstore->getAllmcstore() in mcstore/ControllerPublic/MCStore.php at line 34
    mcstore_ControllerPublic_mcstore->actionRead() in XenForo/FrontController.php at line 310
    XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
    XenForo_FrontController->run() in C:/xampp/htdocs/dev/index.php at line 13
    So is there anyway I can change it so that it doesn't read from the subdomain, or set it to an IP?
     
  5. 0xym0r0n

    0xym0r0n Well-Known Member

    Well it's in the first line- the table does not exist in the database you are trying to read from.
    I'm not sure what else you're talking about with subdomains and such. I'm not sure if that really matters if the config file is pointed to correctly and the table name is correct.

    Is the table name "xf_simple_text" the same in the read and write databases? I suspect there might be a slight typo in your select table_name in the first few instructions of the tutorial.

    And I'm not trying to be mean. I'm also wondering if you did create the database xf_mcstore_text? Is it there?

    Make sure all the table_names are correct basically!
     
  6. My table "xf_mcstore_text" is there, but the code is for some reason trying to add "dev" infront of it.
     
  7. arcaneex

    arcaneex Active Member

    Is it possible to read from a xenforo template?
     
  8. Zephyr

    Zephyr Well-Known Member

    Hello, thanks for the tutorial :)
     
  9. Zephyr

    Zephyr Well-Known Member

    Hello, here:

    [​IMG]

    I have an error:

    [​IMG]


    Is this normal please ?
     
  10. Zephyr

    Zephyr Well-Known Member

    Resolved.
     
  11. Insane54

    Insane54 New Member

    I know this is quite a bump, but I'm trying to do this and getting a security error (even though I've included "<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />" in the HTML section for the page. Any ideas how I can fix the security error?

    Thank you!
     
  12. 0xym0r0n

    0xym0r0n Well-Known Member

    what's the exact error?
     
  13. Insane54

    Insane54 New Member

    Security error occurred. Please press back, refresh the page, and try again.
     
  14. 0xym0r0n

    0xym0r0n Well-Known Member

    could you provide the code you used?
     
  15. Insane54

    Insane54 New Member

    I believe I followed all the instructions perfectly (actually copy and pasted the code step by step), only thing I changed is adding the security token as mentioned earlier in the thread.

    Code:
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
     
    <ul class="tabs Tabs" data-panes="#simpleTextPanes > li">
    <li class="active"><a href="{$requestPaths.requestUri}#write">Write</a></li>
    <li><a href="{$requestPaths.requestUri}#read">Read</a></li>
    </ul>
    <ul id="simpleTextPanes">
    <li id="write">
    <form action="{xen:link 'simpletext/write'}" method="post" class="xenForm">
    <dl class="ctrlUnit">
    <dt><label for="ctrl_message">{xen:phrase message}:</label></dt>
    <dd><textarea name="simple_text" class="textCtrl Elastic" id="ctrl_message" rows="5"></textarea></dd>
    </dl>
    <dl class="ctrlUnit submitUnit">
    <dt></dt>
    <dd><input type="submit" value="{xen:phrase send_message}" accesskey="s" class="button primary" /></dd>
    </dl>
    </form>
    </li>
     
    <li id="read" class="profileContent" data-loadUrl="{xen:link simpletext/read}">
    <span class="jsOnly">{xen:phrase loading}...</span>
    </li>
    </ul>
     
  16. 0xym0r0n

    0xym0r0n Well-Known Member

    needs to be included in the <form></form> somewhere. Personally, I put the security line after the submit input.
    If that doesn't work I'm not sure what went wrong lol
     
    Insane54 likes this.
  17. Zephyr

    Zephyr Well-Known Member

    Hello, possible to cache Xenforo integration with symfony2 ?
     
  18. Insane54

    Insane54 New Member

    Ah! I can't believe I overlooked that! Thank you :)
     
    Fuhrmann and 0xym0r0n like this.
  19. Fuhrmann

    Fuhrmann Well-Known Member

    For a better reading, this resource is also available here in this link.
     
  20. Is it any differant? I couldn't get the one on here to work ever.
     

Share This Page