Jump to content

MDobleZ

Members
  • Posts

    21
  • Joined

  • Last visited

Posts posted by MDobleZ

  1. Yeah, I knew that much. But I didn't know it was still the case after I'd sent the variables with the js function. I thought that if I either opened or refreshed the php after executing this function I would see the variables echoed. In any case, I'll try to do what I was originally trying to do and see if it works. For the time being, I appologize to everyone for having wasted your time and thank you very much for your help.     

  2. I'm beginning to think the mistake is even more stupid than I'd thought, but based on some phps I'd created before I expected to see the echoed string if I opened the php itself. I thought that was a good way of checking if it was working. Am I wrong (and stupid)?

  3. This is what is echoed:
    Notice: Undefined index: q in /home/vol1/getfreehosting.co.uk/getfh_6562567/htdocs/chat/li.php on line 3

    Notice: Undefined index: r in /home/vol1/getfreehosting.co.uk/getfh_6562567/htdocs/chat/li.php on line 4
    query string is SELECT pass FROM chat WHERE nick='' 
    db return is

  4. As an amateur (a flagrant one), I try to avoid using anything unless I find it absolutely necessary, and until now, I had never had problems with javascript. I guess it's time for a change, but I would still like to know what is going wrong with the original code; I'm certain it has to be something silly.   

  5. You're right shadowing, that's what I meant, but adding "/" did not do it. It actually gave me an error message in the developer / network tab mentioned by teynon. I've already done this in the past with an almost identical code, so it has to be a stupid mistake. 

  6. I'm trying to do something which I've done before but for some reason (which has to be a silly one) it doesn't work now. This is the js: 

     

    var userName;

    var password;

     

    function logIn(){

     

    userName=document.f.un.value;

    password=document.f.pa.value;

     

    xmlhttp2=new XMLHttpRequest();

    xmlhttp2.open("POST","li.php",true);

    xmlhttp2.setRequestHeader("Content-type","application/x-www-form-urlencoded");

    xmlhttp2.send("q="+userName+"&r="+password);

    document.getElementById("iden").style.visibility='hidden';

    }

     

    (I know the variables are working, because if I add alert I see them.) And this is the php: 

     

    <?php 

    $q=$_POST["q"]; 

    $r=$_POST["r"]; 

    $con2=mysql_connect("","","");

    mysql_select_db("",$con2);

    $result=mysql_query("SELECT pass FROM chat WHERE nick='$q'");

    $row=mysql_fetch_array($result);

    echo $row[0];

    mysql_close($con2);

    ?>

     

    I know the function is working because if a change $_POST["q"] by $_POST["any nick"], it echoes the pass.
  7. html tags appear when I retrieve info from a table. This is my .js:

     

    function receive()

    {

    var xmlhttp=false;

    xmlhttp=new XMLHttpRequest();

     

    xmlhttp.open("GET","step2.php",false);

    xmlhttp.onreadystatechange=function()

    {

    if (xmlhttp.readyState==4 && xmlhttp.status==200)

    {

     

    document.getElementById("answer").innerText=xmlhttp.responseText;

    }

    }

     

    xmlhttp.send();

     

    }

     

    And this is my .php:

     

     

    <html>

    <body>

    <?php

    $con2=mysql_connect("sql108.getfreehosting.co.uk","getfh_6562567","19770514");

    mysql_select_db("getfh_6562567_fch",$con2);

    $result=mysql_query("SELECT message FROM chat WHERE Id=1");

    $row=mysql_fetch_array($result);

    echo $row[0];

    mysql_close($con2);

    ?>

    </body>

    </html>

     

    What am I doing wrong?

     

    Thanks.

×
×
  • 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.