thank you very much for all your suggestions! I finally found the error!!! I was working on Windows server when i wrote the code and remote server is Linux based, for this reason i didn't see a mistake on the uppercase letter of the table name!
Question
i'm having a problem with a php page on my webserver:
Warning: Invalid argument supplied for foreach() in /home/vyhtpnwt/public_html/include/main.php on line 12
Line 12 on the page is:
foreach ($conn->query("SELECT * FROM accountType WHERE id=".$accountTypeID) as $row2) {
$accountType = $row2[$lang['dbLabel']];
if ($row2['expirationDays']==999) {$accountExp = $lang['unlimitedExp'];} else {
//expiration date script!
$accountExp = 0;
}
Considering that:
$conn works properly on other scripts;
$accountTypeID is populated and it's = 1;
he SELECT return 1 result;
fields expirationDays
$lang['dbLabel'] and $lang['unlimitedExp'] are correctly populated.
what can be the problem?
Thanks in advance for your precious help!!!
La solution 2
Autres conseils
You should try this:
$q = $conn->query
("SELECT * FROM
accountType WHERE id=".
$accountTypeID);
$ar = $q->fetch_assoc():
foreach( $ar as $row2)
{
// your code here
}
Because you haven't actually fetched the array from that code, you simply fetched the mysqli_query object itself, which isn't the array of values you want/need
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow