Jump to content
xisto Community
Sign in to follow this  
kakingho

Question~about Mysql ALTER TABLE `xxx` ORDER BY `no`;

Recommended Posts

I didn't see that you were using ` instead of ' ... but after seeing the error output is is obviuos.You should never use ` as a quote! You don't need the quotes around the table and column name anyway. Just remove them.That should fix it.

Share this post


Link to post
Share on other sites

Everyone mentioned it! You used

mysql_query(ALTER TABLE `xxx` ORDER BY `no`) or die ("Error:".mysql_error());
when you're supposed to have the quotes!

 

Try this on line 9.

mysql_query("ALTER TABLE 'xxx' ORDER BY 'no'") or die ("Error:".mysql_error());

P.S. Please understand this! Replace the line, OK?

211490[/snapback]


pawitp, by using Post #8 data,

I tested different kind of quotes and I now find that quotes MUST NOT be added around table and colunm.

 

However, in this topic, many visitors just asked me to change the quote's sign or omit the semi colon.

So I think many people miss this rule.

>> quotes MUST NOT be added around table and colunm.

By the way , thanks for no9t9's help~~ :P:P

Hope no one make this mistake again ~

 

----------------------------------------------------------------------

SUMMARY

Only this code can run~

mysql_query('ALTER TABLE xxx ORDER BY no');

All of following codes CANNOT work.

mysql_query(ALTER TABLE `xxx` ORDER BY `no`;);
mysql_query(ALTER TABLE `xxx` ORDER BY `no`);
mysql_query('ALTER TABLE `xxx` ORDER BY `no`');
mysql_query('ALTER TABLE \'xxx\' ORDER BY \'no\'');
mysql_query("ALTER TABLE `xxx` ORDER BY `no`");
mysql_query("ALTER TABLE 'xxx' ORDER BY 'no'");

Share this post


Link to post
Share on other sites

Are you trying to update the actual items in your table or just the whole table? Maybe Alter is not the right word to use, try UPDATE if you want to "update" or edit items in table xxx. I'm not sure with this one but you can give it a try.$query = "update xxx set field1='field1_entry' where ID='1' "; mysql_query($query);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.