gamesmstr Posted November 18, 2008 Share Posted November 18, 2008 Not sure if this is the right place for this. It is a mix of JS and PHP but the formatting problem I am having is in the PHP part. I am using an onclick event to call the following function: <script type="text/javascript"> function movenorth() { document.getElementById("outlandsbox").innerHTML = "<?php if ($_SESSION['email']){ $email=$_SESSION['email']; $password=$_SESSION['password']; } $id=$_SESSION['uid']; $uy=$_SESSION['uy']; $_SESSION['reload']='y'; if ($uy > 0){ mysql_query("Update outland_user_data set uy=uy-1 where id='$id'"); } OutlandsMain($email, $password); ?>"; } </script> The fuction doesn't work, but the query launches every time the page is loaded. I know it has to do with my use of quotes. I also noticed that when I tried this: echo 'test $email $password'; it returns this: test $email $password instead of the values of the variables. help? Quote Link to comment https://forums.phpfreaks.com/topic/133221-trouble-with-quotes/ Share on other sites More sharing options...
premiso Posted November 18, 2008 Share Posted November 18, 2008 Use double quotes to display the actual variable data and single quotes to display the literal version of the variable. <?php $pass = "test"; echo $pass; // = test echo '$pass'; // = $pass echo "$pass"; // = test echo '' . $pass . ''; // = test echo '{$pass}'; // = test (because of the { } ) ?> Hope that clears it up. Quote Link to comment https://forums.phpfreaks.com/topic/133221-trouble-with-quotes/#findComment-692862 Share on other sites More sharing options...
gamesmstr Posted November 18, 2008 Author Share Posted November 18, 2008 Right, but this is inside the "" of a .innerHTML call. It is wrecking havoc on my typical coding. Quote Link to comment https://forums.phpfreaks.com/topic/133221-trouble-with-quotes/#findComment-692867 Share on other sites More sharing options...
premiso Posted November 18, 2008 Share Posted November 18, 2008 Well you asked for an in-depth explanation and that is why. If you want more help I would suggest posting the code for OutlandsMain($email, $password); Because that is what outputs to the JS, not the code above, the issue/error would be in there. Quote Link to comment https://forums.phpfreaks.com/topic/133221-trouble-with-quotes/#findComment-692871 Share on other sites More sharing options...
gamesmstr Posted November 18, 2008 Author Share Posted November 18, 2008 I'm sorry I should have been a bit more specific, The problem that I am having is in the formatting for my query. I do need to remove that function call though. It is a php function and I can call it elsewhere. Quote Link to comment https://forums.phpfreaks.com/topic/133221-trouble-with-quotes/#findComment-692872 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.