0

I've been looking at this for a while and I think the major issue is the file i am referencing but I am not sure. I am working with a large amount of php files scattered all over the project folder but in the immediate folder I am working with files NavBar.php which is called using a require() statement in layout.php here's the code I am having trouble with (btw all of this code is in NavBar.php):

             <?php

                $db=mysql_connect('localhost','root','');
                if(!$db) {
                    die('Could not connect: '.mysql_error());
                }
                $connection_string=mysql_select_db('shipreq_stagetest',$db);
                $selectSQL='SELECT * FROM color_patterns';       
                $queryset=mysql_query($selectSQL);
                $num=mysql_num_rows($queryset);
                if(0==$num) {
                    echo "No record";
                    exit;
                } else {
                    while($row=mysql_fetch_assoc($queryset)) {?>
                    <li class= "list_item"  onclick="<?php $indx = $_POST['pat_id'];?>">
                        <?php echo($row['name']);?></li><?php
                    }
                }
                ?>  

I know the sql calls are outdate and I should change it to PDOs I will make the switch as soon as I can figure out why the AJAX isn't working. this php code makes a db call and retrieves some data which displayed in the li (new li generated for each row in the table)(dropdown) and when a user clicks it I want to use this JS function to save the index of the clicked li to a php variable (hence the AJAX, I am really new to AJAX so I am having trouble figuring it out):

        <script>

            $(document).on('click', '.list_item', function() {
                var indx = $(this).index();
                $.ajax({ // add ajax code here
                type: 'POST',
                url: 'layout.phtml',
                data: {pat_id: indx}, // send parameter like this
                success: function(response) {
                       console.log(response);
                }
                });
            });


        </script>

I think the major issue might be the file I am referencing since NavBar.php is referenced by layout.phtml which is probably required by some other document in the hierarchy. this is the error I get in the console when I click on the li:

jquery.min.js:4 XHR finished loading: POST "http://localhost/shiprequest/layout.phtml".send @ jquery.min.js:4ajax @ jquery.min.js:4(anonymous function) @ shiprequest?lang=en:235dispatch @ jquery.min.js:3r.handle @ jquery.min.js:3 shiprequest?lang=en:240
( ! ) Fatal error: Uncaught exception 'Zend_Acl_Exception' with message 'Resource 'shiprequest_layout.phtml' not found' in C:\sgm\library\Zend\Acl.php on line 364 ( ! ) Zend_Acl_Exception: Resource 'shiprequest_layout.phtml' not found in C:\sgm\library\Zend\Acl.php on line 364 Call Stack #TimeMemoryFunctionLocation 10.0006145888{main}( )..\index.php:0 20.0018168016require_once( 'C:\sgm\application\bootstrap.php' )..\index.php:5 30.11182860576Zend_Controller_Front->dispatch( )..\bootstrap.php:124

jszobody
  • 28,495
  • 6
  • 61
  • 72
H.H.
  • 49
  • 10
  • Please [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Jun 17 '16 at 14:24
  • Uncaught exception 'Zend_Acl_Exception' with message 'Resource 'shiprequest_layout.phtml' not found – Marc Giroux Jun 17 '16 at 14:27
  • This looks pretty clear *"'shiprequest_layout.phtml' not found' "* – Jay Blanchard Jun 17 '16 at 14:27
  • yeah it is a referencing issue I am going to try to dig through the hierarchy to see which file references layout.phtml and use that as the url instead. I've noted the mysql * functions and i mean to change it I've just been preoccupied by the AJAX errors and will make the change soon – H.H. Jun 17 '16 at 14:52

1 Answers1

0

From the message error provided by you:

Uncaught exception 'Zend_Acl_Exception' with message 'Resource 'shiprequest_layout.phtml' not found

Validate if shiprequest_layout.phtml exist. You probably wanted to write shiprequest_layout.html and not .phtml

<script>

        $(document).on('click', '.list_item', function() {
            var indx = $(this).index();
            $.ajax({ // add ajax code here
            type: 'POST',
            url: 'layout.html',  <------ here
            data: {pat_id: indx}, // send parameter like this
            success: function(response) {
                   console.log(response);
            }
            });
        });


    </script>

EDIT from Comments:

If you file is really layout.phtml, then your error is in file Acl.php (C:\sgm\library\Zend\Acl.php) at line 364. Line 364 is trying to find shiprequest_layout.phtml if this file do not exist, you will get this error.

You probably mean layout.phtml instead of shiprequest_layout.phtml

Marc Giroux
  • 186
  • 1
  • 7
  • 18
  • but the file in the directory is named layout.phtml, yeah I just double checked – H.H. Jun 17 '16 at 14:30
  • 'shiprequest_layout.phtml' not found' in C:\sgm\library\Zend\Acl.php on line 364 : Modify line 364 for layout.phtml instead of shiprequest_layout.phtml I have edited my answer. – Marc Giroux Jun 17 '16 at 14:31
  • on line 364 in Acl.php it's simply a function trying to locate a resource throws an exception if the resource is not foudn and it can't find layout.phtml because I think layout.phtml is referenced by another file which is the resource .I'll look deeper in the hierarchy to see where layout is required but I honestly have no clue. Thank you for your help though. – H.H. Jun 17 '16 at 14:46
  • Let us know your find. Thanks – Marc Giroux Jun 17 '16 at 14:46
  • totally lost. I am sure now it's because i am not referencing the right resource and might have to make a new instance for this specific case but finding the right file is going to take a while. Thanks for your help. – H.H. Jun 17 '16 at 15:30