Jump to content
john_jack

error in module :customers

Recommended Posts

hi ,

 

i folowed the tutorial on Appml : http://www.w3schools.com/appml/appml_php.asp but i am getting an error .

 

my question is : does anyone know what is wrong with this ? if not is there a way to get more info about the error so ill try to fix it .

 

Heres the Screen shot :

 

l3L3SC4.png

 

Thank You

Share this post


Link to post
Share on other sites

thank you for your response ,

i am actualy folowing the tutorial mentioned above ,but heres the code :

 

the html page :

 

<!DOCTYPE html>
<html lang="en">
<title>Customers</title>
<link rel="stylesheet" href= "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="http://www.w3schools.com/appml/2.0.3/appml.js"></script>
<body>
 
<div class="container" appml-data="appml.php?model=customers">
<h1>Customers</h1>
<table class="table table-striped table-bordered">
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
</tr>
  <tr appml-repeat="records">
    <td>{{CustomerName}}</td>
    <td>{{City}}</td>
    <td>{{Country}}</td>
</tr>
</table>
</div>
 
</body>
 
</html>

 

customer.js code :

 

{
"rowsperpage" : 10,
"database" : {
    "connection" : "mydatabase",
    "sql" : "SELECT * FROM Customers",
    "orderby" : "CustomerName"
}
}

 

appml_config.php

 

<?php echo("Access Forbidden");exit();?>
{
"dateformat" : "yyyy-mm-dd",
"databases" : [{
    "connection" : "mydatabase",
    "host" : "localhost",
    "dbname" : "test",
    "username" : "root2",
    "password" : "toor" 
}]
 
}

also using the appml.php 2.0.3 the one available for download on the TUtorial

Share this post


Link to post
Share on other sites

i created it teh databse directly from mysql coz the create_customers not working .

the point is my database is created and populated .yet not retriving data.

 

thanks :D

Share this post


Link to post
Share on other sites

No, the point is i don't know what you have done, and i am trying to establish what you have or have not done to cause this problem, did you mention anything about the create_customer.js No! did you say you created the database manually No! just gave us a image, then showed us your code after I! asked for it.

Share this post


Link to post
Share on other sites

i folowed the tutorial as it was at first but didnt work ,didnt create the database .so i though maybe if i created it it will resolve the issue but sadly no .

 

i used the sql provided in create_customer.js to create the table .

 

when i use a php file to retrive data and make the result as json it works .

 

 

i know these kinda tutorials are usualy to be 100% working ,but idk man ! thats why i asked if theres a way to get more details about the error somehow :s

 

anything else i can provide you that might help?

Share this post


Link to post
Share on other sites

Show collation of fields?, they should be 'ut8_general_ci'

 

using this sql automatically resets it to this

DROP TABLE IF EXISTS customers;
CREATE TABLE IF NOT EXISTS customers (CustomerID INT(6) NOT NULL PRIMARY KEY AUTO_INCREMENT,CustomerName NVARCHAR(255),ContactName NVARCHAR(255),Address NVARCHAR(255),City NVARCHAR(255),PostalCode NVARCHAR(255),Country NVARCHAR(255));

INSERT INTO customers(CustomerName,ContactName,Address,City,PostalCode,Country)VALUES ("Alfreds Futterkiste","Maria Anders","Obere Str. 57","Berlin","12209","Germany");

INSERT INTO customers(CustomerName,ContactName,Address,City,PostalCode,Country)VALUES ("Around the Horn","Thomas Hardy","120 Hanover Sq.","London","WA1 1DP","UK");

INSERT INTO customers(CustomerName,ContactName,Address,City,PostalCode,Country)VALUES ("Blauer See Delikatessen","Hanna Moos","Forsterstr. 57","Mannheim","68306","Germany");

I followed tutorial, did the same as you and entered data with above, opened new customers.html (end of tutorial) and it worked fine, it requires unicode character set, using NVARCHAR causes it use required collation of 'ut8_general_ci'

 

Also if using windows o/s it will forgive you for using 'Customers' instead of 'customers' (phpmyadmin changes it to all lowercase unless you change settings to disable it) while other O/S or web host server will be less forgiving and treat it as a different table.

Share this post


Link to post
Share on other sites
<?php
echo("Access Forbidden");
exit();

//Note: dbname value all lowercase because phpmyadmin
?>
{
"dateformat" : "yyyy-mm-dd",
"databases" : [{
"connection" : "mydatabase",
"host" : "xxxxxxxx",
"dbname" : "demodb",
"username" : "xxxxxxx",
"password" : "xxxxxxx"
}]
}

Note: lowercase of table name

{
"rowsperpage" : 10,
        "database" : {
        "connection" : "mydatabase",
                "sql" : "SELECT * FROM customers",
                "orderby" : "CustomerName"
        }
}
<!DOCTYPE html>
<html lang="en">
    <title>Customers</title>
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
    <script src="http://www.w3schools.com/appml/2.0.3/appml.js"></script>
    <body>

        <div class="container" appml-data="appml.php?model=customers">
            <h1>Customers</h1>
            <table class="table table-striped table-bordered">
                <tr>
                    <th>Customer</th>
                    <th>City</th>
                    <th>Country</th>
                </tr>
                <tr appml-repeat="records">
                    <td>{{CustomerName}}</td>
                    <td>{{City}}</td>
                    <td>{{Country}}</td>
                </tr>
            </table>
        </div>

    </body>
</html> 

appml.php as downloaded

Share this post


Link to post
Share on other sites

It can also depend on how you saved these files, if you use proper php/html editor it would saved them by default using utf-8 encoding, windows notpad unless specifically selected or mac text editor by changing saving settings will most likley save as ascii encoded.

  • Like 1

Share this post


Link to post
Share on other sites

Oh man i ,i was about to tell you still didnt work!! and you posted the thing about the encoding and that was it man ; UTF8 ftw :D

 

thanks a lot for your help it works like a charme now .

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...