ALTER TABLE - MYSQL QUERY HELP

Im trying to use the alter table function in mysql but I dont know if I am doing it right…

[php]mysql_query(“INSERT INTO prueba (ID, NAME, DESCRIPTION)
VALUES (NULL,’$name’,’$desc’)”) or die(mysql_error());

	mysql_query(" ALTER TABLE prueba AUTO_INCREMENT = 1
        VALUES (NULL,'$name','$desc')") or die(mysql_error()); 	[/php]

Error:

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 ‘VALUES (NULL,‘ljnlkj’,‘lkjh’)’ at line 2

help…

Hi there,

It will be easier to advise you on what to do if you can a bit clearer on what you are trying to achieve?

I deleted record # 20

i want to make another one being - #20

but it goes to #21

… its because of the auto_increment function

I just want to make it +1

I found somewhere that i have to make a query: ALTER TABLE tablename AUTO_INCREMENT = 1

i just dont know how to put it in the code

thanx… btw

Hi there,

try using the PHP function below:
[php]
echo mysql_insert_id();
[/php]

If not, you may need to run an SQL query with “ORDER BY id DESC” and take the first returned value (highest current id) and use that.

Let me know if either of these have helped or just further confused you!

echo mysql_insert_id(); ----> this didnt work…

wats the code for the query?

SELECT
`id`
FROM
`prueba`
ORDER BY
`id` DESC
LIMIT 1

That will return the highest id in that table.

yes but… can you tell me exactly what I need to do?? I have that code but have to add it to what other code? Like for example: do i need to make a query? In that case, can you tell me what query? What html coding is needed to reference that query?

… sryy im new to this… maybe its more simple than I think…

nvm i found it

Sponsor our Newsletter | Privacy Policy | Terms of Service