Pyro-Tech Posted September 7, 2006 Share Posted September 7, 2006 Hello, i am having an issue and this was one of the first places i thought to try posting.I have a table in one database named minerva, the table called minerva_users that has the fields of username, user_password, and user_email....i want to write to a different table named accounts and with the fields name, password, email, and an additional field names state with a default of 0what i want it to do, is copy the username to name, minerva_password to password, and minerva_email to email, and then set the state to 1....here is my attempt at the query:[code]SELECT username, user_password, user_email FROM `minerva_users`;while($row = mysql_fetch_assoc($query)){ echo $row['name'].'<br />'; echo $row['`password`'].'<br />'; echo $row['email'].'<br />'; SET state='1'}[/code]when i enter this query, i get this error:[code]#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 'while($row = mysql_fetch_assoc($query)){echo $row['name'].'<br />'' at line 1 [/code]and is there a way to have it do this periodically or anything?any help would be appreciated....i am needing a seperate table for a script im running, and don't want to cause damage to the table that this info is comming from Quote Link to comment Share on other sites More sharing options...
.josh Posted September 7, 2006 Share Posted September 7, 2006 from your code that you posted, your query is just sitting there, not assigned as a string to a variable, or even just used as a string in a query function. Also, according to your post, the field names for minerva_users have minerva_ prefix, right? It should look something like this:[code]$sql = "SELECT username, user_password, user_email FROM minerva_users";$query = mysql_query($sql);while($row = mysql_fetch_assoc($query)){ echo $row['minerva_name'].'<br />'; echo $row['minerva_password'].'<br />'; echo $row['minerva_email'].'<br />'; SET state='1'}[/code]however, you know that in phpmyadmin you can create a new table based off another table, data and all, right? Quote Link to comment Share on other sites More sharing options...
fenway Posted September 7, 2006 Share Posted September 7, 2006 That, and where's the UPDATE statement? Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 7, 2006 Share Posted September 7, 2006 one other thing you may want to check into if you have access to run manual queries is simply to do a [url=http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-select-into-table.html]SELECT INTO[/url].hope this helps Quote Link to comment Share on other sites More sharing options...
.josh Posted September 7, 2006 Share Posted September 7, 2006 yeah i was gonna eventually point out that if he was going to do it with php, that that's only like half of it. just wanted to make sure he had it working first. Quote Link to comment Share on other sites More sharing options...
Pyro-Tech Posted September 8, 2006 Author Share Posted September 8, 2006 ok...i thought the echo part is where it was writing the info it got from the first sectionhow do i copy the info into a new table then with different field names?and in all honesty i don't know any MySQL so all the questions asking if i knew something...answer is prolly no :-[ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.