Error when trying to run queries on different DB
Permalink
Hi everyone,
I have a frustrating problem running some basic mysql commands within a C5 template. Please see this page for example:
http://www.asxtips.com.au/see-the-benefits/daily-stock-recommendati...
Strangely, this wasn't a problem when the site was on another server.
I'm very new to concrete 5 and am picking the reigns with this site from a previous developer.
Would appreciate anyone who can shed light on fixing this issue.
Thank you,
Tayfun
I have a frustrating problem running some basic mysql commands within a C5 template. Please see this page for example:
http://www.asxtips.com.au/see-the-benefits/daily-stock-recommendati...
An unexpected error occurred. mysql error: [: ] in EXECUTE("select arID, arOverrideCollectionPermissions, arInheritPermissionsFromAreaOnCID from Areas where cID = '66' and arHandle = 'footer-left'") Fatal error: Uncaught exception 'ADODB_Exception' with message 'mysql error: [: ] in EXECUTE("insert into Logs (logType, logText, logIsInternal) values ('exceptions',
Strangely, this wasn't a problem when the site was on another server.
I'm very new to concrete 5 and am picking the reigns with this site from a previous developer.
Would appreciate anyone who can shed light on fixing this issue.
Thank you,
Tayfun
Anyone? :(
What I can tell from the error that there is an unquoted string in the INSERT statement for the first field 'logType':
Fix that and the issue should fixed, I hope :)
"insert into Logs (logType, logText, logIsInternal) values ('exceptions,
Fix that and the issue should fixed, I hope :)
The way I deal with these is by changing the db call from...
$db->Execute('Select * from someTable.....
...to...
$query = 'Select * from someTable.....'
$db->Execute($query);
...then just before the db call I kill the process...
$query = 'Select * from someTable.....'
die(print($query));
$db->Execute($query);
This outputs the query to the screen as the db would interpret it and I can then see if there are any mysql syntax errors such as unquoted strings...
$db->Execute('Select * from someTable.....
...to...
$query = 'Select * from someTable.....'
$db->Execute($query);
...then just before the db call I kill the process...
$query = 'Select * from someTable.....'
die(print($query));
$db->Execute($query);
This outputs the query to the screen as the db would interpret it and I can then see if there are any mysql syntax errors such as unquoted strings...
@JimboJetset: Good tip :)
There are also some "coding guidelines" for PHP/MySQL. Use Double Quotes to enclosed your query. Use singles quotes to enclose field names. All MySQL commands are UPPERCASE. I forget where I saw the guidelines, but if I'll post if I find them.
See for some examples:
http://knol.google.com/k/jayadev-kamath/php-mysql-beginner-guide/14...
There are also some "coding guidelines" for PHP/MySQL. Use Double Quotes to enclosed your query. Use singles quotes to enclose field names. All MySQL commands are UPPERCASE. I forget where I saw the guidelines, but if I'll post if I find them.
See for some examples:
http://knol.google.com/k/jayadev-kamath/php-mysql-beginner-guide/14...