Im aware this code might be vulnerable to SQL injection, it doesn't matter, this is a private home project that will never go public , the only person that can access this other than me is my dad and brother.
Im making a site where you press certain buttons, it sends you to a shop, but the shop doesn't load because of this error:
<b>Notice</b>: Trying to get property of non-object in <b>shop.php</b> on line <b>12</b>
What could be wrong? I have tried looking for solutions on the internet but I found none.
This is the lines of code that this is affecting:
if (!isset($HTTP_RAW_POST_DATA)) {
$HTTP_RAW_POST_DATA = file_get_contents("php://input");
$doc = new DOMDocument();
$doc->loadXML($HTTP_RAW_POST_DATA);
$intShopId = $doc->getElementsByTagName('intShopId');
$shop_id = $intShopId->item(0)->nodeValue;
The last line in this case is line 12.
I know the reason of this is because $intShopId
is not an object. I think it needs to be a global variable passed as a parameter, but in this individual case I cant figure out whats wrong and i would appreciate some help.
There might be some grammatical and/or spelling errors in the question here, I apologize if this is the case. I'm from Sweden.
The problem is going to be with this line:
$intShopId = $doc->getElementsByTagName('intShopId');
since there is no such tag as an <int>
- or even any tag that even begins with that, then that method is returning null, or something else that isn't helpful.
you are probably looking to use a method like :
$doc->getElementById('intShopId');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.