Question:
Problem with PHP an Ajax. How can I fix this problem?
markjaysontimbol
2010-11-03 21:32:51 UTC



$q = $_GET['q'];

$sql="SELECT * FROM tbl_product WHERE productCode = '".$q."'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);

echo "






";

do{
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
}while($row = mysql_fetch_assoc($result));

echo "
Product Name Price SRP Quantity Ordered Total Amount
" . $row['productName'] . "" . $row['price'] . "" . $row['srp'] . "" . $row['optimumLevel'] . "" . $getQa['totalAmount'] . "
";

The error is: Undefined index: q
Please Help
Five answers:
naveed7299
2010-11-03 23:59:10 UTC
First of all, turn off unnecessary error reporting by changing the error_reporting variable in php.ini to false or 0. Generally you should not turn off error reporting while you are developing the application. Turn it off only when you deploy it online or on a network. Create a system that reports errors to you, yourself, rather than making the user uncomfortable.



Next, check when the error reporting is off, does the thing work properly at all. If it doesn't, then the q variable is not properly supplied, perhaps. If you need any more help, you will have to post more details.
2010-11-03 22:06:13 UTC
I would check the syntax of this section



}

xmlhttp.open("GET","po.php?q="+str,tr…

xmlhttp.send();

}



It seems as thought the JavaScript is not properly building the URL link which appears to be po.php?q=somethingsomethingsomething
2016-10-14 09:59:54 UTC
it incredibly is fairly a browser subject. I had the comparable subject this morning. i'm working IE on living house windows Vista. as quickly as I encountered this subject, I clicked the 'Compatibility View' button beside the addressbar - it incredibly is an icon of a torn sheet of paper, good via the 'Refresh' and 'supply up' buttons and that regarded after the subject. wish that enables.
Onitz
2010-11-03 21:40:07 UTC
you ought to have an alternative code incase q is undefined



ie unless the url has something like index.php?q=123456



$_GET['q'] will most likely be undefined





try replacing $q=$GET['q']; with $q=1;



It might also be because you dont have any records in the database, hope this helps
Ryan
2010-11-03 21:33:34 UTC
cheese


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...