Announcement

Collapse
No announcement yet.

testing your phonebook example.

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

  • testing your phonebook example.

    hello,

    i am trying to make your phonebook program, but it do nothing and not showing any errors. code is below.

    what i am doing wrong ? Please Suggest!

    thank you.!




    --global function

    function GetItems()
    myValues={action="get"};

    tabAuth={UserName="newuser",Password="pass"};
    result = HTTP.Submit("http://www.spacepage.in/phonebook.php", myValues, SUBMITWEB_GET, 20, 80, tabAuth,nil);

    myPos=String.Find(result,";;",1,false);
    total=String.Left(result, myPos+1);
    result=String.Replace(total, ";;", "",false);

    if total=="" then
    total=0;
    error_code = Application.GetLastError();
    if (error_code ~= 0) then
    -- some kind of error has occurred!
    Dialog.Message("Error", "error: "..error_code);
    Application.Exit();
    end
    end

    --ListBox.DeleteItem("list", -1);

    for count=1,total do
    myPos=String.Find(result, ";;",1,false);
    currentItem=String.Left(result, myPos+1)
    result=String.TrimLeft(result, currentItem);
    currentItem = String.Replace(currentItem, ";;","",false);

    if Math.Mod(count,2)~=0 then
    itemData="name";
    else
    itemData="number";
    end

    ListBox.AddItem("list",currentItem, itemData);
    end
    ListBox.SelectItem("list",1);
    end


    function AddItem()
    tabAuth={UserName="newuser",Password="pass"};

    input1=Input.GetText("name");
    input2=Input.GetText("number");
    myValues={action=add, name=input1, number=input2};

    HTTP.Submit("http://mywebsite/phonebook.php", myValues, SUBMITWEB_POST, 20, 80, tabAuth,nil);


    Input.SetText("name","");
    Input.SetText("number","");
    GetItems();

    end


    function DeleteItem()
    result=ListBox.GetSelected("list");
    ItemType=ListBox.GetItemData("list", result[1]);
    Item=ListBox.GetItemText("list", result[1]);

    myValues={action="delete", type =ItemType, id=Item};
    HTTP.Submit("http://mywebsite/phonebook.php", myValues, SUBMITWEB_GET, 20, 80, nil, nil);
    GetItems();
    end




    --php script on website



    <?php
    $link = mysql_connect("localhost", "spacepag_newuser", "KzndSUdrr=-;");
    mysql_select_db("spacepag_phonebook",$link);
    if ($action=="get") {
    $query="SELECT * FROM data ORDER by name";
    $result=mysql_query($query,$link);
    while($data=mysql_fetch_assoc($result)) {
    foreach($data as $key=>$value){
    $myData.=$value.";;";
    $total++;
    }
    }
    echo $total.";;".$myData;
    }
    if($action=="add"&&$name!=""&&$number!="") {
    $query="INSERT IGNORE INTO data VALUES ('$name','$number')";
    mysql_query($query,$link);
    }
    if ($action=="delete") {
    switch ($type) {
    case "name":
    $query = "DELETE FROM data WHERE name ='$id'";
    break;

    case "number":
    $query = "DELETE FROM data WHERE number ='$id'";
    break;
    }
    mysql_query($query,$link);
    }

    ?>

  • #2
    I have not tested this or read it as your php is out of date you should be using mysqli or PDO also have you tested your scrip in the browser and make sure it works before you try and drag it in to AMS?
    Plugins or Sources MokoX
    BunnyHop 2021 Here

    Comment

    Working...
    X