Forum Moderators: open
function myMove() {
var php = "<?php
$q=\"SELECT * FROM variable where id='$theId'\";
$result=mysql_query($q) or die(\"Could not execute query : $q.\" . mysql_error());
while($row=mysql_fetch_array($result)){
$variable=$row[\"variable\"];
}
?>";
var check = setTimeout(function (){
myMove();
},100);
}
Additionally, I connect to the database at the top, as well as set the variable $theId. myMove() runs when the page loads.
When I attempt to run this, the page remains blank, and I get the following error message:
PHP Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hermes/web09/b1333/moo.123star/cgi/board_games/chess/loggedIn/daily/board.php on line 1792
PHP Parse error: syntax error, unexpected T_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hermes/web09/b1333/moo.123star/cgi/board_games/chess/loggedIn/daily/board.php on line 1795
If you have any ideas, please tell me. Thank you.
It looks like whatever you are trying to do, you are doing so every 100 milliseconds, in which case you will never get the results you expect because that is simply too fast.
If you wish to be notified client-side when something on the server changes, i.e. a database field value, then you should do so using sockets, not direct HTTP like you are.
Using a socket you can send data from the server to the client only when the server data changes, and so you don't have to keep checking the server...which is resource intensive.
Your whole approach to the problem needs a cleaner solution or you will definitely run into more problems.