[PHP]New to SAJAX

Results 1 to 3 of 3
  1. #1
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    [PHP]New to SAJAX

    Currently i'm abit expirimenting with SAJAX.
    I just can get this piece of code to work :P
    I'm breaking my head over it for over an hour now :S

    PHP Code:
    <?
        
    require("Sajax.php");
        
    $host "localhost";
        
    $user "floris";
        
    $pass "<PASS>";
        
    $db "testit";
            
        
    $sql mysql_connect($host$user$pass);
        
    $con mysql_select_db($db$sql);
        
        if (!
    $con)
        {
            die(
    "Error["mysql_errno() ."]: "mysql_error());
        }
        
        function 
    send($name) {
            
    $query mysql_query("INSERT INTO `sajax` VALUES ('$name')"); //I've named my table 'sajax'
            
    if (!$query)
            {
                die(
    mysql_error());
            }
        }
        
        
    sajax_init();
        
    // $sajax_debug_mode = 1;
        
    sajax_export("send");
        
    sajax_handle_client_request();
        
    ?>
    <html>
    <head>
        <title>Test</title>
        <script>
        <?
        sajax_show_javascript
    ();
        
    ?>
            
        function send() {
            var name;
            
            name = document.getElementById("name").value;
            x_send(name);
        }
        </script>
        
    </head>
    <body>
        <input type="text" name="name" id="name" value="Test" size="10">
        <input type="button" name="check" value="Go"
            onclick="send(); return false;">
    </body>
    </html>
    I have no idea what's wrong..
    It should just input the name in the DB, but now it only does a blank input..


  2. #2
    Elite Member andrew951 is offline
    Member +Rank
    Dec 2006 Join Date
    207Posts

    Re: [PHP]New to SAJAX

    PHP Code:
    <?php 
        
    require("Sajax.php"); 
        
    $host "localhost"
        
    $user "floris"
        
    $pass "<PASS>"
        
    $db "testit"
             
        
    $sql mysql_connect($host$user$pass); 
        
    $con mysql_select_db($db$sql); 
         
        if (!
    $con
        { 
            die(
    "Error["mysql_errno() ."]: "mysql_error()); 
        } 
         
        function 
    send($name) { 
            
    $query mysql_query("INSERT INTO `sajax` VALUES ('$name')"); //I've named my table 'sajax' 
            
    if (!$query
            { 
                die(
    mysql_error()); 
            } 
        } 
         
        
    sajax_init(); 
        
    // $sajax_debug_mode = 1; 
        
    sajax_export("send"); 
        
    sajax_handle_client_request(); 
         
    ?> 
    <html> 
    <head> 
        <title>Test</title> 
        <script> 
        <? 
        sajax_show_javascript
    (); 
        
    ?> 
             
        function send() { 
            var name; 
             
            name = document.getElementById("name").value; 
            x_send(name); 
        } 
        </script> 
         
    </head> 
    <body> 
        <input type="text" name="name" id="name" value="Test" size="10"> 
        <input type="button" name="check" value="Go" 
            onclick="send(); return false;"> 
    </body> 
    </html>
    i had problems yesterday for not putting <?"php" no quote.
    try that. im not sure why i had problems. but idk!

  3. #3
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [PHP]New to SAJAX

    Didn't work =x
    Thanks for trying though

    EDIT:
    Found it!
    Looked through some sources, and found out I needed a to do in JS e.x: function send_cb { } (add the cb), and do that over with each function i've made.



Advertisement