Jump to content

priti

Members
  • Posts

    461
  • Joined

  • Last visited

Posts posted by priti

  1. I was wondering how I can let other users see the what I inputed.

     

    For example, a chat.

     

    Hi,

     

    Well i haven't tried any chat application in AJAX but how about you explore the networking possibilities in PHP????? Welll let me try weather its possible in PHP or not like this By that time you can explore ajax chat script from net.

     

    Regards,

  2. Hello,

     

    I think fsockopen() or CURL doesn't depend on this parameter.I had tested it.pls reproduce

     

    1.switch of allow_url_fopen

    2.run the below script with filename changes

     

    <?php

    if( ini_get( 'allow_url_fopen' )) {

    echo 'url fopen is open';

    } else {

    echo "url fopen is off" ;

    }

     

    $fp = fsockopen("localhost", 80, $errno, $errstr, 30);

    if (!$fp) {

        echo "$errstr ($errno)<br />\n";

    } else {

        $out = "GET test.txt HTTP/1.1\r\n"; //change file name

        $out .= "Host: localhost \r\n";

        $out .= "Connection: Close\r\n\r\n";

    echo $out;

        fwrite($fp, $out);

        while (!feof($fp)) {

            echo fgets($fp, 128);

        }

        fclose($fp);

    }

     

    ?>

     

    allow_url_fopen paramter affects functions like fopen(remote url),file(),file_get_content.

     

    anywayz i would be googling more for this issue and as far as i know CURL is an external lib and never read that it depend on this parameter.

     

    kindly let me know weather above script worked or not.

     

     

    Regards

  3. Hi,

     

    Think that you are getting register and at the same time some else also hitting the server and trying to get register.Now for you and for the other fellow server will run different thread to finish the work and return the response.Have you ever seen that you get registered and you are getting someone else confirmation on screen??/

    So when you are creating an image the image processing will be done of your end (think of uploading an avatar on your profile) .This work is done in your session.hence none other will get this image until and unless it is coded like that i.e to show all image uploaded or processed in 1 min or so :-).

     

    regards

     

  4. for example I have several textareas on the same page, and I wanna collect all the data entered in insert into my MySQL database, but the problem is I dun know the name's for each of the textareas

     

    just lemme give u an example:

     

    <?php
    
    $a = mysql_query("SELECT * FROM `table` WHERE `this` = 'that'");
    while$b = mysql_fetch_array($a))
    {
    echo '<textarea name="body_'.$b['id'].'" cols="50" rows="3"></textarea>';
    }
    
    ?>
    

     

    how could I collect all the body_ID#? I figured it out how to do it if there only exists just one textarea:

     

    <?php
    
    if(isset($_POST)){
    foreach($_POST as $value => $item)
    {
    $id = explode('_', $value);
    
    mysql_query("UPDATE `table` SET `this` = '".$item."' WHERE `id` = '".$id[1]."'");
    }
    }
    
    echo '<form method="post" action="/test.php">';
    
    $a = mysql_query("SELECT * FROM `table` WHERE `this` = 'that'");
    while($b = mysql_fetch_array($a))
    {
    echo '<div><textarea name="body_'.$b['id'].'" cols="50" rows="3"></textarea></div>';
    }
    
    echo '<div><input type="submit" value="Submit" /></div></form>';
    
    ?>
    

     

    I hope this makes sense. lol just dun really know how else to explain it :D Anyway, I'd really appreciate any ideas/help/comments on this. Thanks.

     

    Well your coding is confused me kindly run this script and you will get the idea how you can get the name of your textarea

     

     

    <?php

    $a=array('1','2','3');?>

    <form action="<?php $_SERVER['PHP_SELF']?>" method='post'>

    <?php

    foreach($a as $k)

    {

    echo '<textarea name="body_'.$k['id'].'" cols="50" rows="3"></textarea>';  ///from your piece of code

    }

     

    echo '<input type="submit" name="submit" value="submit">';

    echo '</form>';

    if(isset($_POST))

    {

    print_r($_POST);

    }

    ?>

     

    Hope it helps,

     

    Regards

  5. Hi,

     

    It 's very simple If and else ...

     

    1.mysql_num_rows return number of records fetched form your query.

    So

     

    2.if number of record == 1 then

      row = mysql_fetch_assoc($query); script tries to fetch the data from the recordset  after that

     

    3.

    if($row['Active'] == 1)

    {

    session_start();

    $_SESSION['user_id'] = $row['ID'];

    $_SESSION['logged_in'] = TRUE;

    header("Location: members.php");

    }

    else {

              $error = 'Your membership was not activated. Please open the email that we sent and click on the activation link';

    }

     

    4. Above snippet explain if you are active member then user's info is inserted in $_SESSION and redirected to members.php page BUT if you active state is not 1 then message will get display ($error).

     

    5. IF mysql_num_rows($query) is not equals 1

      then $error = 'Login failed !';

     

    //For this else there is one missing IF condition .In your code provided that is missing.

    else {

    $error = 'Please use both your username and password to access your account';

    }

     

    Hope it gives a fair amount of knowledge to you to understand what this script is doing.

     

    Regards

     

  6. I have a simple form

     

    <form name=myForm>

    <input type="text" name="username" />

    <input type="submit" value=Submit />

    </form>

     

    <?PHP

    if(isset($_POST['submit'])){

    $username=$_POST['username'];

    $fields = array(username);

    $values = array($username);

    $db->insert($fields,$values,'customer');

    echo "data added";

    }

    ?>

     

    I want to insert data to database table using POST method. How do i do that using ajax?

     

     

     

    Hi,

     

    Making AJAX POST request is very easy if you are aware of simple ajax stuff.

     

        http_request = new XMLHttpRequest(); //XMLHttpRequest method has to be defined to create xmlHttprequest

        http_request.onreadystatechange = function() {s=alertContents(http_request)};

        frmstr='name=priti?age=25&gender=f&job=yes&designation=developer';

        http_request.open('POST', "./tests.php", true);

        http_request.send(frmstr);

     

    And if you don't want to use this go for jquery ajax.It is easy and smooth.

     

    regards

  7. hello dear,

     

    I was debugging the issue and i see some detailed error

     

    Error: uncaught exception: [Exception... "Object cannot be created in this context"  code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)"  location: "http://content.gannettonline.com/global/s_code/s_code.js Line: 446"]

     

    kindly in to s_code.js.I think you should try to remove error with s

    i.e

    s has no properties

    http://www.timesofacadiana.com/scripts/s_local_customization.js

    Line 2

     

    there is something related with this s.

    kindly share if you are able to solve or else let me know what this 's' is all about which is causing second error.

     

    regards

  8. That's sort of what I want to do...here is my code:

     

    $query = mysql_query("SELECT text FROM table WHERE something = '$something' ");

     

    while($row = mysql_fetch_assoc($query))

     

    $insert = mysql_query("INSERT INTO table (1,2,3,4) VALUES ('$id','$something','$something', '{$row['text']}') ");

     

     

    I can echo the row but it will not insert. Funny thing is that this same script works on another page...I just can't figure out what the difference is....

    Here i See...response in CAPS

     

    $query = mysql_query("SELECT text FROM table WHERE something = '$something' ");

    --YOU FETCHED TEXT

     

    while($row = mysql_fetch_assoc($query))

    --RUNNING A LOOP TO INSERT THE FETCHED TEXT

     

    $insert = mysql_query("INSERT INTO table (1,2,3,4) VALUES ('$id','$something','$something', '{$row['text']}') ");

     

    --here you are inserting the fetched and form posted data.If your register_global in php.ini is off then you have to fetch  posted form data values from $_POST array.you should not use {} in query i never use it in plain queries.Even till now you are not able to get the idea then copy the query and run in SQL mode in mysql and see what output you are receiving.

     

    the logic seems to be alright but because you are not posting the correct piece of code it would be diffcult for any one to help you.

     

    anyways try these hope it solves your problem .

  9. Hello,

     

    If i am write then you want to upload the image file and see on the same page withot refreshing the whole page.

     

    If this is true then try to get help of AJAX to upload the file.Let me remind you cann't do fileuploads with ajx but there is a trick to do that.It will help you to upload the file and then your can read and show the image as soon as it is in the location.

     

    try to find or google class called AjaxFileUploader.I had worked with the same but its a big set of file i cann't attach or share here.Hope it work for you also.

     

    Happy coding

    Regards

  10. Hello,

     

    Two ways you can do

     

    1.create the html in php and return i.e your responseText='<td>name</td><td>age</td><td>class</td>'

    and print this directly.

     

    2.return a string with a delimiter

    name-age-class

    hence your response text would be name-age-class then in javascript your can split this with the help of delimiter '-' and show as you want in the javascript.

     

    Hope it helps

    Regards

  11. Hi

     

    I am having a customer list page.I have a delete button using anchor tag.If I want to delete a customer an alert should come and if the customer is having a pending invoice then one more alert should come.I have written this using ajax page by getting customer id.

     

    function Isconfirm(id)			
    {
        var  aid          = id;
        var  http_request = false;
        var s;
        if (window.XMLHttpRequest)  // For Mozilla, Safari,...
            http_request = new XMLHttpRequest();
        else if (window.ActiveXObject)  // For IE
        {
          try
          {
               http_request = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e)
          {
            try {
                 http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
          }
        }
        if (!http_request)
        {
          alert('Giving up  Cannot create an XMLHTTP instance)');
          return false;
        }
        
        http_request.onreadystatechange = function() {s=alertContents(http_request);
    
    };
        http_request.open('GET', "./getcusid.php?id="+aid, true);
        http_request.send(null);
      	 if(s === false)
    {
    alert("not entered");
    return false;
    }
    else
    {
    return true;
    }
    
    }
    function alertContents(http_request)
    {
      if (http_request.readyState == 4)
      {
        if (http_request.status == 200)
        {
          var tid = http_request.responseText;
    var res = confirm('Are you Sure you want to delete this customer?');
        if(res && tid!=0)
      var res1 = confirm('The selected customer has a non-zero balance.Deleting this customer will cause an adjusting transaction to be created.Is this Ok?');
         else 
        	return false;
       if (res1)
           return true;
    else 
    return false;
    }
    else
        alert('There was a problem with the request.');
    }
    }
    

     

    The getcusid.php page returns the value of tid;The above ajax code is  returning true  value if ok or cancel button is clicked.

     

    Please Help............

     

     

    Hello rekha,

     

    Its simple if your print variable before

    if(s==false) it will print 'undefined' .

    you have defined var s in the function but it is initialsed in other funtion either you make s global  in this script or edit your script as follow

      http_request.onreadystatechange = function() {s=alertContents(http_request);

    if(s === false)

    {

    alert("not entered");

    return false;

    }

    else

    {

    alert('return ture');

    return true;

    }

    It work gr8 in both way

    hope you have good time ahead in coding

     

    regards

  12. I've googled this, but I just can't figure out what in the world it could be.

     

    Firefox says: Object cannot be created in this context" code: "9

     

    the code responsible is the "http.send();":

    function sndReq(action) {
       http.onreadystatechange = handleResponse;
      http.send();
    }

     

    if you want to see it in action, you can do so here:

    http://68.228.8.85/timesphotocontest/

     

    What is this error, and how do I make it go away?

     

     

    Hello ,

     

    kindly check  http.open('get', 'imagelist.php?action='+(action?action:"")); line of code for proper formation of URL and secondly, when we make a get request write http.send(null).

     

    Regards

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.