I got a little problem here with my SQL query...
I debugged where the problem resides and realized that the varchar/text
column seemed to stop my php function.
Here is my code:
$queryTest = mysqli_query($link, "SELECT dos_nom,dos_id FROM dossier");
while($dataTest = mysqli_fetch_assoc($queryTest)) {
if($dataTest['dos_id'] == $myparameter) {
$toreturn.= '<option class="text-'.$dataTest['dos_id'].'" value="'.$dataTest['dos_nom'].'" selected>'.$dataTest['dos_nom'].'</option>';
}
}
The problem is in the value $dataTest['dos_nom']
. Without which my query works (it prints the page normally), but I don't know why. With it, it doesn't work (it prints the top of the page, and nothing from/after my php function)...
To be precise, i use it in an ajax function.
Thanks in advance!
EDIT: I tried to print only 1 row from 'dos-nom', it works! But i when try to print out more than 1 row, the function stops!
My code:
$queryTest2 = mysqli_query($link, "SELECT * FROM dossier");
while($dataTest2 = mysqli_fetch_assoc($queryTest2))
{
$test[0] = $dataTest2['dos_nom'];
}
if($dataTest['dos_id'] == $dos_id)
{
$toreturn.= '<option class="text-'.$dataTest['dos_id'].'" >'.$test[0].'</option>';
}
It prints only the last line this way. If i put a WHERE in the query it will stop the function, so i don't know what to do!
ANSWER:
É / À were in my database, i replaced them by E and A, problem solved!
try to use addslashes() function like
addslashes($dataTest['dos_nom'])
maybe the value contains some backslash or some junk characters which may be breaking your code