PHP/Ajax/jQuery - Passing a jquery value to a php script
Wondering why you have a prepared statement in your code but not actually using it properly.
$stmt = $dbh->prepare("SELECT * FROM tblbookings WHERE bookref = :data");$stmt->execute(array( ':date' => trim($rowdata),));
I've added trim()
to make sure there are no spaces or newlines around it that could mess things up.
Update
It's debug time:
public static function getGridRow($rowdata) { $rowdata = $_GET['data']; echo $rowdata;
Add the following lines:
echo "=====DEBUG====== "; var_dump($rowdata); echo " =====DEBUG====== "; exit;
This will write the value and immediately stop your script so you can inspect its value in detail.
Use functions
HtmlSpecialChar() Trim()
then display $rowdata variable and if string is in correct format then
try this
$query = ("SELECT * FROM tblbookings WHERE bookref = '$rowdata'");
or
$query = ("SELECT * FROM tblbookings WHERE bookref = '".$rowdata."'");
PHP can see variable without -> '
Try to aislate your problem first. You say you have no problem with firebug, try to put here the console.dir()
response to validate.
Mean while do the following:
Then see yor $_REQUEST
var with a print_r()
. Is your variable there?. If so, do a var_dump($_REQUEST['rowdata'])
and check.
In public static function getGridRow($rowdata)
see that you overwrite $rowdata
to see the echo. And finally if you have all alright by now prepare correctly your query