Jump to content

What's Wrong With This?


miocene

Recommended Posts

I'm trying to insert some columns into my sql table with this:

$sql2="ALTER TABLE payments ADD '{payed[$num_users]}' DECIMAL( 10, 2 ) NOT NULL AFTER '{topay[$num_users2]}' ,ADD '{fs[$num_users]}' DECIMAL( 10, 2 ) NOT NULL AFTER '{payed[$num_users]}' ,ADD '{topay[$num_users]}' DECIMAL( 10, 2 ) NOT NULL AFTER '{fs[$num_users]}' ";mysql_query($sql2);

the name and position of the columns depend on variable $num_users(and $num_users2 which = $num_users - 1)it doesn't give me any error but doesn't do anything either!

Link to comment
Share on other sites

Try adding exit(mysql_error()); if i'm using th right syntax (think so)had this to , but thanks to justsomeguy giving me this suggestion i found something was wrong with the query :)
hmm really? My other requests don't have that and they seem to work fine!
Link to comment
Share on other sites

It would also be a good idea to print the query out and compare it with the ALTER TABLE syntax from the MySQL documentation. Generally, column names are not quoted. Strings are quoted, not identifiers. You can either put table and column names in `backquotes` or leave the quotes off (if the identifiers don't have any syntax problems where the quotes aren't necessary).

Link to comment
Share on other sites

hmm really? My other requests don't have that and they seem to work fine!
This isn't a way to get your code working. It's a way to find out why it's not working.Also, as implied by justsomeguy, do
var_dump($sql2);

and see if it outputs a valid SQL query by either trying it in another environment (MySQL Query Browser for example) or better yet, by comparing it against the MySQL documentation.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...