katai Posted November 21, 2012 Share Posted November 21, 2012 Hey! I got Insert into table Name and Content but when I add into name it switches place with content. So name -> Content and Content -> Name :/ Anyone knows a fix or what's wrong? Link to comment https://forums.phpfreaks.com/topic/270962-mysql-insert-switching-names-and-place/ Share on other sites More sharing options...
requinix Posted November 21, 2012 Share Posted November 21, 2012 It probably has something to do with your code. Which we can't see right now... Link to comment https://forums.phpfreaks.com/topic/270962-mysql-insert-switching-names-and-place/#findComment-1393978 Share on other sites More sharing options...
katai Posted November 21, 2012 Author Share Posted November 21, 2012 http://pastebin.com/m5gfNtK3 here mate Link to comment https://forums.phpfreaks.com/topic/270962-mysql-insert-switching-names-and-place/#findComment-1393979 Share on other sites More sharing options...
requinix Posted November 21, 2012 Share Posted November 21, 2012 Couldn't just post it? function addPost($pName, $pAuth, $pContent,$pCat = 1) { $query = mysql_query("INSERT INTO posts VALUES(null,'$pName','$pAuth','$pContent','$pCat')") or die(mysql_error()); } Specify the names for the fields... INSERT INTO table (field1, field2, field3) VALUES ("value 1", "value 2", "value 3") INSERT INTO table SET field1="value 1", field2="value 2", field3="value 3" because I bet your problem is that you haven't noticed how the order of the fields in the table don't agree with the order of the fields in your SQL. Link to comment https://forums.phpfreaks.com/topic/270962-mysql-insert-switching-names-and-place/#findComment-1394003 Share on other sites More sharing options...
katai Posted November 22, 2012 Author Share Posted November 22, 2012 oh thanks alot man, will try it out =) Link to comment https://forums.phpfreaks.com/topic/270962-mysql-insert-switching-names-and-place/#findComment-1394441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.