elitecodex
19 years ago
Hey everyone. I have this query
select * from `TableName` where `SomeIDField` > 0
I can open a mysql command prompt and execute this command with no
issues. However, Im trying to issue the same command inside of
mysql_real_query and I keep on getting this error back.
"You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '' at line 1"
I added \n's to my string to determine that its not liking the end of
my query. So here is the quick snippet of code.
stl::string query ="select * from `TableName` where `SomeIDField` > 0";
// .... some other non-important stuff ...
if ( mysql_real_query(&m_Mysql, query.c_str(), query.length()+2) != 0 )
{
status->Error(mysql_errno(&m_Mysql), "Query failed! [" +
stl::string(mysql_error(&m_Mysql)) + "]");
}
So thats it. What am I missing?
Also, a side question. The above line only works with the third
parameter being query.length() + 2. +1 Gives me a seg fault. Why is
this? Isn't the null character a single character??
Thanks for all help in advance!
select * from `TableName` where `SomeIDField` > 0
I can open a mysql command prompt and execute this command with no
issues. However, Im trying to issue the same command inside of
mysql_real_query and I keep on getting this error back.
"You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '' at line 1"
I added \n's to my string to determine that its not liking the end of
my query. So here is the quick snippet of code.
stl::string query ="select * from `TableName` where `SomeIDField` > 0";
// .... some other non-important stuff ...
if ( mysql_real_query(&m_Mysql, query.c_str(), query.length()+2) != 0 )
{
status->Error(mysql_errno(&m_Mysql), "Query failed! [" +
stl::string(mysql_error(&m_Mysql)) + "]");
}
So thats it. What am I missing?
Also, a side question. The above line only works with the third
parameter being query.length() + 2. +1 Gives me a seg fault. Why is
this? Isn't the null character a single character??
Thanks for all help in advance!