I'm trying to do a simple query:
SELECT
job_title,
job_description,
job_tasks,
technology_skills,
job_activities
FROM
careeryou_db3
WHERE
Job_Interests = " CIE"
It works perfectly in mysql giving me this result:
However, when I use this in my PHP it returns an empty data set. I did some troubleshooting by trying to query the columns one by one and it works(returning the correct results respectively.
SELECT
job_title, job_description, job_tasks
FROM
careeryou_db3
WHERE
Job_Interests = " CIE"
Apparently, when I try to query anything from the columns of [technology_skills] OR [job_activities], the php result would return as BLANK. Does anyone have any idea why? this is strange and im kinda new to this
This is my php code:
$query = 'SELECT job_title,job_description,job_tasks FROM careeryou_db3 WHERE Job_Interests = " CIE" ';
$resultset = mysql_query($query, $connection);
$records = array();
while($r = mysql_fetch_assoc($resultset)){
$records[] = $r;
}
echo json_encode($records);
I can't see any error on your sql syntax. Can you check the mysql logs for better error information?
See here for details https://dev.mysql.com/doc/refman/5.7/en/error-log.html
[mysqld]
log_error=/var/log/mysql/mysql_error.log
general_log_file=/var/log/mysql/mysql.log
It would help how you call the mysql, place the query build code as example.
It might be worth adding these lines for extra debugging to ensure your connection and query is successful.
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
....
It is because of the data in those columns that are conflicting with the PHP. Apparently this "—" cannot get parse into PHP which explains why the query works only in phpMyAdmin and not my PHP script.