PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
i'm getting an error inserting an e-mail into a database?!
this is non-sense to me, i feel like i have collected a million addresses on at least 10 different servers and i've never run into this.
it appears to be having troubles reading the @ symbol!?
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 '@thevariables.com' at line 1
does this seem outright bizarre? i've never seen this. i'm using the exact some code in unison on another site with no err.
Last edited by $var on Wed Apr 18, 2007 12:11 pm, edited 1 time in total.
prints just @ for both my utf8 and latin1 database.
Nevertheless mysql_real_escape_string (or similar) is mandatory.
It would also be helpful to print the actual query that failed (when debugging)
@ has special meaning in MySQL if used outside of string context, but if you're using it in a string it should be fine. More than likely the MySQL parser just choked on where exactly the problem was. But yes, always escape variable data before adding it to a query.
FYI, @ is a variable operator for stored procedures or simply for storing results in complex routines.
aaronhall wrote:I didn't think user-defined variables were interpreted in a string context. confused..
No they're not. I was making a separate informative comment As I mentioned in my earlier post, I think MySQL's parser is just returning the error at the wrong point. It's not the first time I've seen it point to the wrong place in the query. I imagine it's to do with the way it tokenizes the query or something. Either way, the issue will be fixed with use of mysql_real_escape_string()
Wow we're having such nice weather in the UK at the moment Bliss.
Ahh, sorry, I got caught up in the @ hoopla. I glanced over the thread and assumed that had been identified as the culprit. Anyway, send some of that nice weather over my way.
volka wrote:
I'd better not ask what a table having only one field UserDetail_Email is good for.
That's a good question. i have my user data split between two tables, one for qualitative setting and one that is more quantitative and user entered. I found it easier to look at having all the int values in one table, and the human entered varchar in another.
I had seen it done in tutorial, and thought that I would give it a try. So far, I have found it to be less cumbersome to work with as there are about 20 fields (and growing) of user variable settings, and another 15 for profile content.
so, i passed it, and it accepted after i escaped it... but not i'm getting the same error calling it!?
I've tried it both escaped and unescaped, and i still get the error!?!?!
$select = "SELECT * FROM hcw_userDetail WHERE UserDetail_Email = ".mysql_real_escape_string($_POST["email"]);
$result = mysql_query($select, $link) or die (mysql_error() .' : '.htmlentities($link));
Warning: htmlentities() expects parameter 1 to be string
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 '@thevariables.com' at line 1 : SELECT * FROM hcw_userDetail WHERE UserDetail_Email = meaghan@thevariables.com
hmm... perhaps there should be different quotes. i will try that.
Last edited by $var on Wed Apr 18, 2007 12:04 pm, edited 1 time in total.