Announcement

Collapse
No announcement yet.

php include confusion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    php include confusion

    Hi all, im trying to use this method: http://community.actinic.com/showthread.php?t=38957
    of including a file into my layout

    To give some background it creates a double drop down menu (using ajax so theres no page load) which I hopefully once working will modify into a jump menu. It pulls info from two fields in a sql database. Example here: http://www.plus2net.com/php_tutorial..._down_list.php


    The file is called dd.php (which calls on a config file for the DB) and im calling it like this: <script type="text/javascript" src="dd.php"></script>

    The content of this file is:

    <div id="cat">
    <form name="drop">
    <select name=cat onchange="AjaxFunction(this.value);">
    <option value=''>Select Manufacturer</option>
    <?
    require "config.php";// connection to database
    $q=mysql_query("select * from category ");
    while($n=mysql_fetch_array($q)){
    echo "<option value=$n[cat_id]>$n[category]</option>";

    }

    ?>
    </select></div><!--end of manufacturers cat-->
    <div id="subcatid"></div>
    </form>


    which should output something like this:


    <div id="cat">
    <select name=cat onchange="AjaxFunction(this.value);">
    <option value=''>Select Manufacturer</option>
    <option value=1>option1</option>
    <option value=2>option2</option>
    </select></div><!--end of manufacturers cat-->

    <div id="subcatid">other data appears here</div>

    </form>


    But im getting the following error in Actinic: A javascript error has been found on the page ('syntax error').

    My heads gone.what am I doing wrong? What should I check?

    Or.....should I be calling the file like this:

    <actinic:block php="true">
    include_once 'dd.php';
    </actinic:block>

    or

    <actinic:block php="true">
    <? include("dd.php") ;?>
    </actinic:block>



    TIA from a confused design person
    Web design Bradford

    #2
    You are loading a JavaScript file. This file should only contain JavaScript code, not HTML. Therefore your PHP should only output JavaScript source code.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Also can you explain whether you expect to run this code on the server or the Actinic PC?
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Hi Norman,

        Cheers for getting back, you can see how confused ive got.

        It doesn't need to run on a local PC, just the server with the sql database. So im trying to load a file that contains php and html which in turn uses a link to a ajax script so the browser doesn't have to reload the window, hope that is clearer.

        Im now trying


        <actinic:block php="true">
        include_once 'dd.php';
        </actinic:block>

        But getting: A PHP error has been found on the page (parse error on line 2)
        Last edited by DarrenSpink; 02-Oct-2008, 04:19 PM. Reason: extra info
        Web design Bradford

        Comment


          #5
          everyone forget this thread, im going to have to think about what the best solution is in light of new info..thanks anyway.
          Web design Bradford

          Comment

          Working...
          X