28rain Posted February 13, 2009 Share Posted February 13, 2009 From this code <P><strong>Categorie</strong><br> <select name = "categorie"> <option value = "watch">watch</option> <option value = "piercing">piercing</option> <option value = "my_music">my_music</option> </select> onto here (it is definetly posting because all other variables are ill show you full scripts if necessary) $table = "$_POST[categorie]"; $db_name = "testDB"; $table_name = "$table"; and i get this error; Notice: Array to string conversion in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\do_addrecord.php on line 6 Table 'testdb.array' doesn't exist And my_music is definetly a table and i have added data to it previously Thanks Link to comment https://forums.phpfreaks.com/topic/145107-this-arraystring-error-using-the-html-list-option/ Share on other sites More sharing options...
samshel Posted February 13, 2009 Share Posted February 13, 2009 $table = $_POST["categorie"]; try this. Link to comment https://forums.phpfreaks.com/topic/145107-this-arraystring-error-using-the-html-list-option/#findComment-761551 Share on other sites More sharing options...
The Little Guy Posted February 13, 2009 Share Posted February 13, 2009 Move the quotes: $table = "$_POST[categorie]"; So it is like this: $table = $_POST["categorie"]; Link to comment https://forums.phpfreaks.com/topic/145107-this-arraystring-error-using-the-html-list-option/#findComment-761553 Share on other sites More sharing options...
28rain Posted February 13, 2009 Author Share Posted February 13, 2009 Same error just on line 8 ($table_name....) Link to comment https://forums.phpfreaks.com/topic/145107-this-arraystring-error-using-the-html-list-option/#findComment-761554 Share on other sites More sharing options...
28rain Posted February 13, 2009 Author Share Posted February 13, 2009 Took some more quotes out of that the error is now on line 14 give me 5 to check it Link to comment https://forums.phpfreaks.com/topic/145107-this-arraystring-error-using-the-html-list-option/#findComment-761555 Share on other sites More sharing options...
28rain Posted February 13, 2009 Author Share Posted February 13, 2009 ok error on line 14 now (you can see first line) cant see what the problem is. Its the same error... <? if((!$_POST['id'])||(!$_POST['format'])||(!$_POST['title'])){ header( "Location: /show_addrecord.html"); exit; } $table = $_POST["categorie"]; $db_name = "testDB"; $table_name = $table; $connection = mysql_connect("127.0.0.1", "****", "*****) or die(mysql_error()); $db = mysql_select_db($db_name, $connection) or die(mysql_error()); $sql = "insert into $table_name (id, format, title, artist_fn, artist_ln, rec_label, my_notes, date_acq) VALUES ('$_POST[id]', '$_POST[format]', '$_POST[title]', '$_POST[artist_fn]', '$_POST[artist_ln]', '$_POST[rec_label]', '$_POST[my_notes]', '$_POST[date_acq]')"; $result = mysql_query($sql,$connection) or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/145107-this-arraystring-error-using-the-html-list-option/#findComment-761557 Share on other sites More sharing options...
The Little Guy Posted February 13, 2009 Share Posted February 13, 2009 It would be nice to see some more code, unless you have this solved. Link to comment https://forums.phpfreaks.com/topic/145107-this-arraystring-error-using-the-html-list-option/#findComment-761560 Share on other sites More sharing options...
samshel Posted February 13, 2009 Share Posted February 13, 2009 debug. $table = $_POST["categorie"]; var_dump($_POST["categorie"]); Link to comment https://forums.phpfreaks.com/topic/145107-this-arraystring-error-using-the-html-list-option/#findComment-761600 Share on other sites More sharing options...
28rain Posted February 15, 2009 Author Share Posted February 15, 2009 Thanks a million samshell that works! Could you explain to me why this needs to be done?!?! Link to comment https://forums.phpfreaks.com/topic/145107-this-arraystring-error-using-the-html-list-option/#findComment-762660 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.