cilian29 Posted June 5, 2012 Share Posted June 5, 2012 Good Day! I'm starting to learn postgresql using php and right now I'm stuck being a newbie I have limitted understanding if my query is right. I'm trying to copy all from table1(columnA) and paste all on table2(columnA) using pgadmin iii. I noticed that this cannot be done or I really dont know what I'm doing. so I tried insert into query INSERT INTO table2(columnA, columnB) VALUES (table1.columnA, table2.columnB) I then follow this with my php code: $sql ="SELECT * FROM table1"; $result = pg_query($dbconn, $sql); while($row =pg_fetch_array($result)){ $sql2="INSERT INTO table2(columnA, columnB) VALUES ($row[columnA], $row[columnB])"; $result=pg_query($sql2); echo $row[columnA]."<br>"; echo $row[columnB]."<br>"; unfortunately I'm not getting results or error. the last error I got is pg_query is not good resource for postgresql. can anyone shed light cuz I'm pulling my hair for days now. thanks in advance. Link to comment https://forums.phpfreaks.com/topic/263709-insert-into-help/ Share on other sites More sharing options...
btherl Posted June 5, 2012 Share Posted June 5, 2012 When you connect to the database, do you check for errors? Link to comment https://forums.phpfreaks.com/topic/263709-insert-into-help/#findComment-1351411 Share on other sites More sharing options...
cilian29 Posted June 6, 2012 Author Share Posted June 6, 2012 Ok no problem got it solved on my own Link to comment https://forums.phpfreaks.com/topic/263709-insert-into-help/#findComment-1351580 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.