Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP echo, outputting full html code (undesired) before object (desired)
    primarykey
    data
    text
    <p>When I echo $jsonstring, seemingly a whole blank html page is sent over (from PHP to Javascript) with the object I requested. Super new all around here, so I don't get why.</p> <p>my php code:</p> <pre><code>&lt;?php //ini_set('display_errors', '1'); //ini_set('error_reporting', E_ALL); require "localdbcxn.php"; $encoded = file_get_contents('php://input'); $decoded = json_decode($encoded, true); $email = $decoded['email']; $password = $decoded['password']; $identify = mysql_query("SELECT UserId FROM users WHERE UserEmail='$email' AND UserPassword='$password'"); $numrows = mysql_num_rows($identify); $row = mysql_fetch_assoc($identify); $userid = $row['UserId']; $sessionid = mt_rand(1111111111111111,9999999999999999); $sessionkey = mt_rand(1111111111111111,9999999999999999); $logindate = date("Y-m-d H:i:s"); $login = "INSERT INTO mobileSession (UserId, SessionId, SessionKey, BeginDate) VALUES('$userid','$sessionid','$sessionkey','$logindate') ON DUPLICATE KEY UPDATE SessionId='$sessionid', SessionKey='$sessionkey', BeginDate='$logindate' "; if ($numrows == 1) { mysql_query($login); $session = array('UserId'=&gt;$userid,'SessionId'=&gt;$sessionid); $jsonstring = json_encode($session); echo $jsonstring; } ?&gt; </code></pre> <p>Here's what the console(log) shows:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt;{"UserId":"33","SessionId":8207219793564744} </code></pre> <p>From UserID til ...4744 is correct, but can anyone help me understand why the html code is being echoed? In my limited experience, I haven't seen this before, and feel that I am doing something wrong.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload