| | You need to provide more information. How can we tell what is wrong from a single line of code? What is the error message you are getting?? Do you even have a table called xxx and in that table is there a column called no? |
|
|
QUOTE(no9t9 @ Dec 3 2005, 12:55 AM) You need to provide more information. How can we tell what is wrong from a single line of code? What is the error message you are getting?? Do you even have a table called xxx and in that table is there a column called no? Of course i have that table and colunm. I had said before QUOTE CODE mysql_query(ALTER TABLE `xxx` ORDER BY `no`;); Why i cant run the above code?! But i can directly type and run this code in phpmyadmin's sql query CODE ALTER TABLE `xxx` ORDER BY `no`; Actually, there is only a main code. You asked the above question seem to be kidding me. Why don't you read my article completely before replying. Why don't you ask me whether my connection password is correct or not. Anyway, forgive my non-enough information. Here is the whole file. There is no error message with nothing happen. CODE <? $ip="localhost"; $user="xxx"; $pw="xxx"; $link=mysql_connect($ip,$user,$pw)or die ("Could not connect"); mysql_select_db("xxx"); mysql_query(ALTER TABLE `xxx` ORDER BY `no`); mysql_close($link); ?> But i can directly type and run this code in phpmyadmin's sql query CODE ALTER TABLE `xxx` ORDER BY `no`; So I want to know whether php can use order function. What's going on??!
of course i will ask stupid questions if you simply post a statement like "what's wrong... Please correct..." Do you expect people to be mind readers? People need information to in order to resolve problems.
1) in your sql query statement you don't need the quotes around the table name or the column name (but this should't be causing the problem). 2) you talked about user name and password... well did you check them? do they match in your control panel? did you grant permissions to that user to your database you are trying to access? 3) if there is no error message how do you know there was an error? if you've already run the query in phpmyadmin, the table will already have been ordered according to the query. if you run the same query again, nothing will happen 4) make sure you are selecting the right database in your mysql_select_db function 5) the code looks fine to me, so it is not a coding issue 6) use mysql_error funtion so that it tells you what the error is (if there is one). 7) And last, I used the 'ALTER TABLE xxx ORDER BY yyy' function and it works fine. CODE <? $ip="localhost"; $user="xxx"; $pw="xxx"; $link=mysql_connect($ip,$user,$pw) or die ("Error:".mysql_error()); mysql_select_db("xxx") or die ("Error:".mysql_error()); mysql_query(ALTER TABLE `xxx` ORDER BY `no`) or die ("Error:".mysql_error()); mysql_close($link); ?>
Here is my full report.
User name , password, permission,etc .. all are normal~ 1. can run successfully ( this code is for testing only) CODE <? $ip="localhost"; $user="xxx"; $pw="xxx"; $link=mysql_connect($ip,$user,$pw) or die ("Error:".mysql_error()); mysql_select_db("xxx") or die ("Error:".mysql_error()); //mysql_query(ALTER TABLE `xxx` ORDER BY `no`) or die ("Error:".mysql_error()); mysql_query("UPDATE xxx SET ip='test' ,password='test' where no=41"); mysql_close($link); ?> 2. can run this code in phpmyadmin's sql query directly CODE ALTER TABLE `xxx` ORDER BY `no` 3. cannot run this code in phpmyadmin's sql query and a error is shown CODE mysql_query(ALTER TABLE `xxx` ORDER BY `no`) error message QUOTE #1064 - 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 'mysql_query(ALTER TABLE `xxx` ORDER BY `no`)' at line 1 4. After run this file, a error is shown. CODE <? $ip="localhost"; $user="xxx"; $pw="xxx"; $link=mysql_connect($ip,$user,$pw) or die ("Error:".mysql_error()); mysql_select_db("xxx") or die ("Error:".mysql_error()); mysql_query(ALTER TABLE `xxx` ORDER BY `no`) or die ("Error:".mysql_error()); //mysql_query("UPDATE xxx SET ip='test' ,password='test' where no=41"); mysql_close($link); ?> error message: QUOTE Parse error: parse error, unexpected T_STRING in /home/xxx/public_html/test.php on line 9 line 9 means CODE mysql_query(ALTER TABLE `xxx` ORDER BY `no`) or die ("Error:".mysql_error()); * I manage the table into descending order before every testing. * phpmyadmin version: 2.6.4-pl2 * php version: 4.3.10 * PERL version: 5.8.4 please help to solve this strange problem~~
Everyone mentioned it! You used
CODE 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. CODE mysql_query("ALTER TABLE 'xxx' ORDER BY 'no'") or die ("Error:".mysql_error()); P.S. Please understand this! Replace the line, OK?
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. QUOTE(pawitp @ Dec 7 2005, 06:46 PM) Everyone mentioned it! You used CODE 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. CODE mysql_query("ALTER TABLE 'xxx' ORDER BY 'no'") or die ("Error:".mysql_error()); P.S. Please understand this! Replace the line, OK? 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~~ Hope no one make this mistake again ~ ---------------------------------------------------------------------- SUMMARY Only this code can run~ CODE mysql_query('ALTER TABLE xxx ORDER BY no'); All of following codes CANNOT work. CODE mysql_query(ALTER TABLE `xxx` ORDER BY `no`;); CODE mysql_query(ALTER TABLE `xxx` ORDER BY `no`); CODE mysql_query('ALTER TABLE `xxx` ORDER BY `no`'); CODE mysql_query('ALTER TABLE \'xxx\' ORDER BY \'no\''); CODE mysql_query("ALTER TABLE `xxx` ORDER BY `no`"); CODE mysql_query("ALTER TABLE 'xxx' ORDER BY 'no'");
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);
Similar Topics
Keywords : mysql, alter, table, xxx, order
(3) ok i need some more help from the wonderful coders here at Trap. I'm almost done with my CMS Using MySQL?! (4) Hey, I need your help again! I need some good working tutorial how I can update my SQL through anyone any php or mysql editor that is good for noob (6) hi there guys, from my previous posting, i am a noob in php and mysql programming. I want to know anyone knows a code for mysql and php (2) hi everyone! I am making a program using php and mysql...I am a noob on this so i need your (4) Hi I was reminded of this earlier by a post in a topic, meant to post it but forgot and the topic on PHP & MySQL (9) Hello, everyone! I need some tools for those two things to test PHP scripts coming together with While inserting data into MySQL, how can I know if the data I'm in (4) Basically, I want to know if the Data I'm inserting through a Form is already there or not. Sort (4) Ok, so I'm making some arcade administration software so I don't have to add games the hard (3) session_start(); include "database.php"; if (!$_SESSION || $_SESSION { // User (13) QUOTE session_start(); include "database.php"; include "edit.inc.php"; if (!$_SESSION (7) how to get the id number of the loged in user? my db is id. username. password. i have tryed a The Artists is an online programming unit and gfx designing clan. (0) Let's Talk about basic mysql commands used in php. I will now show you a list of the most common Problem with a mysql join (2) Hello I am trying to write a script whereby I can pull an image out of one database table and getting PHP 5 to work with MySQL (0) Just thought this would be of extreme help to those who are planning to migrate to php5 and still (3) Ok I have started useing PHP and MySQL recently and I am wondering how I go about createing an (4) ok, i am hosting a smf (simple machines forum) and in order to do so, i need apache, mysql and php (4) Greetings this tutorial will show you some mysql basics.. MySQL is one of the most used database. a (9) Simple MySQL Query Limiting CODE <?php // If mypage?limit=blah is not defined returs 5 (2) theres a bug somewhere in this query and i can't seem to find it. does anyone else see it? (1) suppose i have a page, page.php?part=1 there i have some text fields. user will give input, but (5) I need help with a couple of things. First, I need to know how to retrieve information from a mysql A very simple help required (4) Im using the following code, for very simple work.. it simply gets and print the comments which are (11) A search engine is provided to facilitate the user with undemanding and clear-cut search options. (7) i've started to learn php..im familiar to basics of php and mysql now.Now for example i want (5) Is there anyway to make subqueries work in MySQL? I'm pretty certain someone out there knows Using Php? (20) I'm learning php in class right now, but I'm still not that good at it, what I'm how to increment a MySQL column one unit (7) Hi, I have a column in a MySQL table which contains a counter of the views of the object described how to make news script that uses MySQL writen in PHP (19) How to make a News script with PHP + MySQL So..in this tutorial i will explain how to create PHP (5) Can someone please help...? I have a problem with using "ORDER BY" in mysql... CODE SELECT * Looking for mysql, alter, table, xxx, order
|
![]() Question~about Mysql - ALTER TABLE `xxx` ORDER BY `no`; |
| ADD REPLY / Got an Opinion! | a humble request :-) | RAPID SEARCH! | Free Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute your information that might help someone here. Ask your Doubts & Queries to get answers.. "Together, We enlight each other!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|