buchberg Posted February 18, 2012 Share Posted February 18, 2012 Windows 7, Apache 2.2.21 / PHP 5.3.5. What does the below error mean? I am new and fighting through this particular piece of code. Thank you in advance for your help. Warning: mysql() expects parameter 3 to be resource, string given in C:\website\do_createtable.php on line 3 <? $db_name="booster"; $connection=mysql("localhost", "USERNAME", "PASSWORD") or die (mysql_error()); $db=mysql_select_db($db_name, $connection) or die (mysql_error()); $sql="CREATE TABLE $_POST[table_name] ("; for ($i=0; $i < count($_POST[field_name]); $i++) { $sql .= $_POST[field_name][$i]." ".$_POST[field_type][$i]; if ($_POST[field_length][$i] != "") { $sql .= " (".$_POST[field_length][$i]."),"; } else { $sql .= ","; } } $sql=substr($sql,0,-1); $sql .= ")"; $result=mysql_query($sql,$connection) or die (mysql_error()); if ($result) { $msg="<P>".$_POST[table_name]." has been created!</P>"; } ?> <HTML> <HEAD> <TITLE>Create a Database Table: Step 3</TITLE> </HEAD> <BODY> <h1>Adding table to <? echo "$db_name"; ?>....</h1> <? echo "$msg"; ?> </BODY> </HTML> Link to comment https://forums.phpfreaks.com/topic/257228-php-form-for-creating-table-in-mysql/ Share on other sites More sharing options...
joel24 Posted February 18, 2012 Share Posted February 18, 2012 you want mysql_connect(), not mysql() Link to comment https://forums.phpfreaks.com/topic/257228-php-form-for-creating-table-in-mysql/#findComment-1318540 Share on other sites More sharing options...
buchberg Posted February 18, 2012 Author Share Posted February 18, 2012 joel24--YOU are the man! Thank you so much and have a good day....buchberg Link to comment https://forums.phpfreaks.com/topic/257228-php-form-for-creating-table-in-mysql/#findComment-1318595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.