itsureboy Posted August 21, 2007 Share Posted August 21, 2007 OK so i have an upload form on my website connected to the upload.php file. Everytime i upload i get this error and it doesnt insert into the table: Warning: mysql_insert_id() [function.mysql-insert-id]: A link to the server could not be established in /home/ls/public_html/lauploadcl.php on line 19 I dont know whats going wrong.... Here is the code: <?php $id = mysql_insert_id(); $category = $_POST['category']; $subcategory = $_POST['subcategory']; $title = $_POST['title']; $preview= $_POST['preview']; $code = $_POST['code']; $background = $_POST['background']; $contact = $_POST['contact']; $extbanner = $_POST['extbanner']; $extwidth = $_POST['extwidth']; $extheight = $_POST['extheight']; $author = $_POST['author']; $description = $_POST['description']; $date = $_POST['date']; $ip = $_POST['ip']; $dbhost = 'localhost'; $dbuser = 'ex'; $dbpass = 'ex'; $dbname = 'ex'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); mysql_query("INSERT INTO `layouts` VALUES ('$id', '$category', '$subcategory', '$title', '$preview', '$code', '$background', '$contact', '$extbanner', '$extwidth', '$extheight', '$author', '$description', '$date', '$ip')"); include 'closedb.php'; ?> Thanks..... Link to comment https://forums.phpfreaks.com/topic/66005-solved-php-insert-mysql-error/ Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 You are using mysql_insert_id() before you are connected to the server. That line needs to be below the mysql_connect() line. Link to comment https://forums.phpfreaks.com/topic/66005-solved-php-insert-mysql-error/#findComment-330050 Share on other sites More sharing options...
itsureboy Posted August 21, 2007 Author Share Posted August 21, 2007 Really.... That is kinda apparent. I just always used it like that on another server and it worked. Lemme give it a try.Thanks.... Link to comment https://forums.phpfreaks.com/topic/66005-solved-php-insert-mysql-error/#findComment-330052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.