JOakley
11-12-2004, 09:42 AM
Hi,
I have recently been introduced to the world of Laszlo and I have been eagerly trying to learn as much as possible.
As the title of the post implies I was working on the contacts tutorial and ran into a problem. I am using PHP to grab data from mySQL, turn it into XML and then it lets laszlo grab it, display it...works perfect. I got to the part with insert/update/delete and what not...nothing!
I continually get the error (debug mode):
NOTE:STRIPPED HTTP:// FROM ERROR MSG SO THE MESSAGE BOARD WOULD NOT TRUNCATE IT
"backend timeout for localhost/contactmgr.php?email=test%40test%2Ecom&phone=123%2D123%2D1234&lastName=lTest&firstName=fTest&pk=&action=insert: null http response body
And right now when I pasted that into this textarea I saw that I am not getting any of the data to populate the URL. I designed everything as per the tutorial with the exception of using php instead of jsp. How, help, please?
[LASZLO CODE]
<!-- data_binding.lzx -->
<!-- Tutorial Link: http://www.laszlosystems.com/lps-2.1.2/tutorials/data_app_8.html -->
<canvas bgcolor="#D4D0C8" debug="true">
<debug x="0" y="200" width="400" />
<dataset name="dset" src="http://localhost/getcontacts.php" request="true" type="http"/>
<!-- 1 -->
<dataset name="dsSendData" request="false" src="http://localhost/contactmgr.php" type="http"/>
<class name="contactview" extends="view" visible="false" x="20" height="120">
<!-- 2 -->
<text name="pk" visible="false" datapath="@email"/>
<text y="10">First Name:</text>
<edittext name="firstName" datapath="@firstName" x="80" y="10"/>
<text y="35">Last Name:</text>
<edittext name="lastname" datapath="@lastName" x="80" y="35"/>
<text y="60">Phone:</text>
<edittext name="phone" datapath="@phone" x="80" y="60"/>
<text y="85">Email:</text>
<edittext name="email" datapath="@email" x="80" y="85"/>
<method name="sendData" args="action">
var d=canvas.datasets.dsSendData; // 3
var p=new LzParam(); // 3a
p.addValue( "action", action, true);
p.addValue( "pk", pk.getText(), true);
p.addValue( "firstName", firstName.getText(), true);
p.addValue( "lastName", lastName.getText(), true);
p.addValue( "phone", phone.getText(), true);
p.addValue( "email", email.getText(), true); // 3b
d.setQueryString( p ); // 3c
d.doRequest(); // 3d
</method>
<!-- 4 -->
</class>
<simplelayout axis="y"/>
<view>
<simplelayout axis="y"/>
<text onclick="parent.newContact.setVisible(!parent.newContact.vi sible);">New Entry...</text>
<contactview name="newContact" datapath="new:/contact">
<button width="80" x="200" y="10">Add
<method event="onclick">
parent.sendData("insert"); // 5
parent.datapath.updateData();
var dp=canvas.datasets.dset.getPointer();
dp.selectChild();
dp.addNodeFromPointer( parent.datapath );
parent.setVisible(false);
parent.setDatapath("new:/contact");
</method>
</button>
</contactview>
</view>
<view datapath="dset:/phonebook/contact">
<simplelayout axis="y"/>
<view name="list" onclick="parent.updateContact.setVisible(!parent.updateCont act.visible);">
<simplelayout axis="x"/>
<text datapath="@firstName"/>
<text datapath="@lastName"/>
<text datapath="@phone"/>
<text datapath="@email"/>
</view>
<contactview name="updateContact">
<button width="80" x="200" y="10">Update
<method event="onclick">
parent.sendData("update"); // 6
parent.parent.datapath.updateData();
</method>
</button>
<button width="80" x="200" y="40">Delete
<method event="onclick">
parent.sendData("delete"); // 7
parent.parent.datapath.deleteNode();
</method>
</button>
</contactview>
</view>
</canvas>
[PHP CODE]
<?php
$host = 'localhost';
$user = 'user';
$password = 'password';
$database = 'database';
$conn = mySQL_CONNECT("$host", "$user", "$password") or die(mySQL_ERROR());
mySQL_SELECT_DB($database, $conn) or die(mySQL_ERROR());
$action = $_GET['action'];
$email = $_GET['email'];
$firstName = $_GET['firstName'];
$lastName = $_GET['lastName'];
$phone = $_GET['phone'];
if ($action == 'insert') {
mySQL_QUERY = ("INSERT into contact (email,
first_name,
last_name,
phone) " . "
VALUES ('$email',
'$firstName',
'$lastName',
'$phone')");
} else if ($action == 'update') {
mySQL_QUERY = ("UPDATE contact SET email = '$email',
first_name = '$firstName',
last_name = '$lastName',
phone = '$phone'
WHERE email = '$pk'");
} else if ($action == 'delete') {
mySQL_QUERY = ("DELETE * FROM contact WHERE email = '$pk'");
}
?>
I have recently been introduced to the world of Laszlo and I have been eagerly trying to learn as much as possible.
As the title of the post implies I was working on the contacts tutorial and ran into a problem. I am using PHP to grab data from mySQL, turn it into XML and then it lets laszlo grab it, display it...works perfect. I got to the part with insert/update/delete and what not...nothing!
I continually get the error (debug mode):
NOTE:STRIPPED HTTP:// FROM ERROR MSG SO THE MESSAGE BOARD WOULD NOT TRUNCATE IT
"backend timeout for localhost/contactmgr.php?email=test%40test%2Ecom&phone=123%2D123%2D1234&lastName=lTest&firstName=fTest&pk=&action=insert: null http response body
And right now when I pasted that into this textarea I saw that I am not getting any of the data to populate the URL. I designed everything as per the tutorial with the exception of using php instead of jsp. How, help, please?
[LASZLO CODE]
<!-- data_binding.lzx -->
<!-- Tutorial Link: http://www.laszlosystems.com/lps-2.1.2/tutorials/data_app_8.html -->
<canvas bgcolor="#D4D0C8" debug="true">
<debug x="0" y="200" width="400" />
<dataset name="dset" src="http://localhost/getcontacts.php" request="true" type="http"/>
<!-- 1 -->
<dataset name="dsSendData" request="false" src="http://localhost/contactmgr.php" type="http"/>
<class name="contactview" extends="view" visible="false" x="20" height="120">
<!-- 2 -->
<text name="pk" visible="false" datapath="@email"/>
<text y="10">First Name:</text>
<edittext name="firstName" datapath="@firstName" x="80" y="10"/>
<text y="35">Last Name:</text>
<edittext name="lastname" datapath="@lastName" x="80" y="35"/>
<text y="60">Phone:</text>
<edittext name="phone" datapath="@phone" x="80" y="60"/>
<text y="85">Email:</text>
<edittext name="email" datapath="@email" x="80" y="85"/>
<method name="sendData" args="action">
var d=canvas.datasets.dsSendData; // 3
var p=new LzParam(); // 3a
p.addValue( "action", action, true);
p.addValue( "pk", pk.getText(), true);
p.addValue( "firstName", firstName.getText(), true);
p.addValue( "lastName", lastName.getText(), true);
p.addValue( "phone", phone.getText(), true);
p.addValue( "email", email.getText(), true); // 3b
d.setQueryString( p ); // 3c
d.doRequest(); // 3d
</method>
<!-- 4 -->
</class>
<simplelayout axis="y"/>
<view>
<simplelayout axis="y"/>
<text onclick="parent.newContact.setVisible(!parent.newContact.vi sible);">New Entry...</text>
<contactview name="newContact" datapath="new:/contact">
<button width="80" x="200" y="10">Add
<method event="onclick">
parent.sendData("insert"); // 5
parent.datapath.updateData();
var dp=canvas.datasets.dset.getPointer();
dp.selectChild();
dp.addNodeFromPointer( parent.datapath );
parent.setVisible(false);
parent.setDatapath("new:/contact");
</method>
</button>
</contactview>
</view>
<view datapath="dset:/phonebook/contact">
<simplelayout axis="y"/>
<view name="list" onclick="parent.updateContact.setVisible(!parent.updateCont act.visible);">
<simplelayout axis="x"/>
<text datapath="@firstName"/>
<text datapath="@lastName"/>
<text datapath="@phone"/>
<text datapath="@email"/>
</view>
<contactview name="updateContact">
<button width="80" x="200" y="10">Update
<method event="onclick">
parent.sendData("update"); // 6
parent.parent.datapath.updateData();
</method>
</button>
<button width="80" x="200" y="40">Delete
<method event="onclick">
parent.sendData("delete"); // 7
parent.parent.datapath.deleteNode();
</method>
</button>
</contactview>
</view>
</canvas>
[PHP CODE]
<?php
$host = 'localhost';
$user = 'user';
$password = 'password';
$database = 'database';
$conn = mySQL_CONNECT("$host", "$user", "$password") or die(mySQL_ERROR());
mySQL_SELECT_DB($database, $conn) or die(mySQL_ERROR());
$action = $_GET['action'];
$email = $_GET['email'];
$firstName = $_GET['firstName'];
$lastName = $_GET['lastName'];
$phone = $_GET['phone'];
if ($action == 'insert') {
mySQL_QUERY = ("INSERT into contact (email,
first_name,
last_name,
phone) " . "
VALUES ('$email',
'$firstName',
'$lastName',
'$phone')");
} else if ($action == 'update') {
mySQL_QUERY = ("UPDATE contact SET email = '$email',
first_name = '$firstName',
last_name = '$lastName',
phone = '$phone'
WHERE email = '$pk'");
} else if ($action == 'delete') {
mySQL_QUERY = ("DELETE * FROM contact WHERE email = '$pk'");
}
?>