I’m building a small app, which is basicly a form built in HTML and jQuery mobile, I’ve deployed it to the web, and to my iOS-version of the app, and it works like a charm. But now when trying to deploy on the android-version of the app, I just get “undefined” on the screen when submiting, no “undefined variable” or anything else, just “undefined”.
Do anyone have some form of solution to this problem? I’m using PhoneGap to deploy HTML/CSS/JQuery
I’m very grateful for any help given.
I’m posting the code here:
<?php
$con = mysql_connect("db-ip","username","password");
if (!$con)
{
die('errormessage: ' . mysql_error());
}
mysql_select_db("dbname", $con);
$myusername=$_POST['username'];
$myusername = stripslashes($myusername);
$myusername = mysql_real_escape_string($myusername);
$sql2="SELECT * FROM users WHERE username='$myusername'";
$result=mysql_query($sql2);
$count=mysql_num_rows($result);
if (empty($myusername))
{
header('Location:error2.html');
exit;
}
if($count==1)
{
$sql="INSERT INTO testresult(slider1, slider2, slider3, slider4, time, user) VALUES('$_POST[slider1]', '$_POST[slider2]', '$_POST[slider3]', '$_POST[slider4]', NOW(),'$myusername')";
}
else
{
header('Location:error.html');
exit;
}
if (!mysql_query($sql,$con))
{
die('errormessage:' . mysql_error());
}
header('Location:done.html');
exit;
mysql_close($con);
?>
If the error is just
undefined, it can’t be caused by PHP. In JavaScript,undefinedmeans that the variable which you are trying to use isn’t defined.Another observation was mysql_ functions. You should consider using PDO instead.
From php.net:
And this was about functions starting with mysql_.