I am trying to add an username and password into a database using JSON. I cannot get it to work, any ideas? Thank you.

<?php
mysql_connect("localhost","sdr001","************");
mysql_select_db("tristate");


$userID = $_POST['userID'];
$password = $_POST['password'];

$q=mysql_query("INSERT INTO users VALUES(>'".$_REQUEST['userID']."'");
while($e=mysql_fetch_assoc($q))
        $output[]=$e;

print(json_encode($output));

mysql_close();
?>

An INSERT query only returns true or false, it does not return a result-set, so the while loop does nothing (other than generate a warning). For the query itself, you may want to remove the >. Also, if your users table contains more columns, then the query will fail.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.