
MDobleZ
-
Posts
21 -
Joined
-
Last visited
Posts posted by MDobleZ
-
-
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.
-
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)?
-
I do get frog and ted, Shadowing.
-
path to file li.php is /home/vol1/getfreehosting.co.uk/getfh_6562567/htdocs/chat/li.php
Got the same results with IE 8.
-
Sorry I didn't asnwer all the questions. I have been able to used the same file to pass a variable to the db, so everything is in place.
-
Still the js code, there are still a few things I'd like to try before giving up on it.
-
I actually get an "not found" error in the developers console is I add "chat/".
-
The php is in my chat folder. Same folder as the js and the html.
-
No, teynon, sorry I didn't see your question. I was responding to shadowing's idea. I no longer get any error from chrome, it was only when I added "/" before "li.php" that I got an error.
-
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 -
Nothing is ever returned. But, as I said before, the variables do get to the php and from there to the mysql db. I agree the problem must be in the sql part of the code, but I can simply not spot it.
-
Manixat, I tried and it didn't work so I thought the variables were not getting to the php. But then I modified the php to insert the variables in the database and it worked, so this keeps getting better and better.
-
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.
-
No errors at all, it's just the variables are not reaching the php. They are in fact in the same directory.
-
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.
-
I mean it doesn't echo anything and I know the reason is the variables are not getting to the php file. I simply don't know why. I'm using chrome, so the request is fine
-
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.
-
Thank you very, requinix, I will.
-
Sorry, but aside from my "come-and-hack-me-I'm-an-idiotic-newbie" move, I see nothing strange in the code. I know that it contains html tags, but so do all the examples I've seen online.
-
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.
Odd problem passing variabels
in PHP Coding Help
Posted
I did, it did and I already echoed the password for my username. Now I have to try the whole code and see what happens, so I'm tagging this as solved. Thanks again for your help.