Proper way to organize MySQL queries in code?

shizo

New Member
I need some ideas to make my code a bit cleaner for a pretty simple application with a simple database. I have the following idea but it's not working quite well. This is what I'm doing:I have many queries on a page (takes up a lot of space and souce code looks messy. I'd like to have an index of them in another PHP file that I could call via an include.Except I ran into a problem. I have a querie that looks like this on the external php page.queries.php:\[code\]$RegisterQuery = sprintf("INSERT INTO `testdb`.`users` ( `user_id`, `username`, `password`, `First Name`, `Last Name`, `email`) VALUES ( NULL, '%s', '%s', '%s', '%s', '%s' );", mysql_real_escape_string($username), mysql_real_escape_string($password), mysql_real_escape_string($first_name), mysql_real_escape_string($last_name), mysql_real_escape_string($email));\[/code\]The problem with this is that even when I don't query \[code\]$RegisterQuery\[/code\] with \[code\]mysql_query()\[/code\] it throws a bunch of MySQL warnings about using the \[code\]mysql_real_escape_string()\[/code\] and about how it can't connect. I don't get how it's doing this when I'm not even querying the database!Then again, I could easily ignore the warnings...I'm just not sure I'm doing this properly in which case I mainly want to ask if there's a better way of doing this or should I just ignore the warnings?Your feedback is greatly appreciated! Thanks in advance.
 
Back
Top