Jump to content

Unknown column in 'field list'


Mutley

Recommended Posts

I recieve this error:

Unknown column 'product_image0_name' in 'field list'

 

But the SQL seems to insert fine if I copy the output and paste it into PHPmyAdmin, so curious why the PHP script generates this error.

 

Query below:

 

<?php

	$Query	=	"INSERT INTO `product_products`(
		`cat_id`,
		`product_name`,
		`product_slug`,
		`product_image0_name`,
		`product_image0_s_width`,
		`product_image0_s_height`,
		`product_image0_m_width`,
		`product_image0_m_height`,
		`product_image1_name`,
		`product_image1_s_width`,
		`product_image1_s_height`,
		`product_image1_m_width`,
		`product_image1_m_height`,
		`product_image2_name`,
		`product_image2_s_width`,
		`product_image2_s_height`,
		`product_image2_m_width`,
		`product_image2_m_height`,
		`product_image3_name`,
		`product_image3_s_width`,
		`product_image3_s_height`,
		`product_image3_m_width`,
		`product_image3_m_height`,
		`product_image4_name`,
		`product_image4_s_width`,
		`product_image4_s_height`,
		`product_image4_m_width`,
		`product_image4_m_height`,
		`product_image5_name`,
		`product_image5_s_width`,
		`product_image5_s_height`,
		`product_image5_m_width`,
		`product_image5_m_height`,
		`product_image6_name`,
		`product_image6_s_width`,
		`product_image6_s_height`,
		`product_image6_m_width`,
		`product_image6_m_height`,
		`product_image7_name`,
		`product_image7_s_width`,
		`product_image7_s_height`,
		`product_image7_m_width`,
		`product_image7_m_height`,
		`product_image8_name`,
		`product_image8_s_width`,
		`product_image8_s_height`,
		`product_image8_m_width`,
		`product_image8_m_height`,
		`product_description`) 
		VALUES (
		'$cat_id',
		'$product_name',
		'".Word2Slug($product_name)."',
		'".$product_image_name[0]."',
		'".$Image[0]['small']['width']."',
		'".$Image[0]['small']['height']."',
		'".$Image[0]['medium']['width']."',
		'".$Image[0]['medium']['height']."',
		'".$product_image_name[1]."',
		'".$Image[1]['small']['width']."',
		'".$Image[1]['small']['height']."',
		'".$Image[1]['medium']['width']."',
		'".$Image[1]['medium']['height']."',
		'".$product_image_name[2]."',
		'".$Image[2]['small']['width']."',
		'".$Image[2]['small']['height']."',
		'".$Image[2]['medium']['width']."',
		'".$Image[2]['medium']['height']."',
		'".$product_image_name[3]."',
		'".$Image[3]['small']['width']."',
		'".$Image[3]['small']['height']."',
		'".$Image[3]['medium']['width']."',
		'".$Image[3]['medium']['height']."',
		'".$product_image_name[4]."',
		'".$Image[4]['small']['width']."',
		'".$Image[4]['small']['height']."',
		'".$Image[4]['medium']['width']."',
		'".$Image[4]['medium']['height']."',
		'".$product_image_name[5]."',
		'".$Image[5]['small']['width']."',
		'".$Image[5]['small']['height']."',
		'".$Image[5]['medium']['width']."',
		'".$Image[5]['medium']['height']."',
		'".$product_image_name[6]."',
		'".$Image[6]['small']['width']."',
		'".$Image[6]['small']['height']."',
		'".$Image[6]['medium']['width']."',
		'".$Image[6]['medium']['height']."',
		'".$product_image_name[7]."',
		'".$Image[7]['small']['width']."',
		'".$Image[7]['small']['height']."',
		'".$Image[7]['medium']['width']."',
		'".$Image[7]['medium']['height']."',
		'".$product_image_name[8]."',
		'".$Image[8]['small']['width']."',
		'".$Image[8]['small']['height']."',
		'".$Image[8]['medium']['width']."',
		'".$Image[8]['medium']['height']."',
		'$product_description')";
?>

 

Thanks in advance,

Nick.

Link to comment
Share on other sites

`product_products` (

  `product_id` int(11) NOT NULL auto_increment,

  `cat_id` int(11) NOT NULL,

  `product_name` varchar(255) NOT NULL,

  `product_slug` varchar(255) NOT NULL,

  `product_image0_name` varchar(255) NOT NULL,

  `product_image0_s_width` int(11) NOT NULL,

  `product_image0_s_height` int(11) NOT NULL,

  `product_image0_m_width` int(11) NOT NULL,

  `product_image0_m_height` int(11) NOT NULL,

  `product_image1_name` varchar(255) NOT NULL,

  `product_image1_s_width` int(11) NOT NULL,

  `product_image1_s_height` int(11) NOT NULL,

  `product_image1_m_width` int(11) NOT NULL,

  `product_image1_m_height` int(11) NOT NULL,

  `product_image2_name` varchar(255) NOT NULL,

  `product_image2_s_width` int(11) NOT NULL,

  `product_image2_s_height` int(11) NOT NULL,

  `product_image2_m_width` int(11) NOT NULL,

  `product_image2_m_height` int(11) NOT NULL,

  `product_image3_name` varchar(255) NOT NULL,

  `product_image3_s_width` int(11) NOT NULL,

  `product_image3_s_height` int(11) NOT NULL,

  `product_image3_m_width` int(11) NOT NULL,

  `product_image3_m_height` int(11) NOT NULL,

  `product_image4_name` varchar(255) NOT NULL,

  `product_image4_s_width` int(11) NOT NULL,

  `product_image4_s_height` int(11) NOT NULL,

  `product_image4_m_width` int(11) NOT NULL,

  `product_image4_m_height` int(11) NOT NULL,

  `product_image5_name` varchar(255) NOT NULL,

  `product_image5_s_width` int(11) NOT NULL,

  `product_image5_s_height` int(11) NOT NULL,

  `product_image5_m_width` int(11) NOT NULL,

  `product_image5_m_height` int(11) NOT NULL,

  `product_image6_name` varchar(255) NOT NULL,

  `product_image6_s_width` int(11) NOT NULL,

  `product_image6_s_height` int(11) NOT NULL,

  `product_image6_m_width` int(11) NOT NULL,

  `product_image6_m_height` int(11) NOT NULL,

  `product_image7_name` varchar(255) NOT NULL,

  `product_image7_s_width` int(11) NOT NULL,

  `product_image7_s_height` int(11) NOT NULL,

  `product_image7_m_width` int(11) NOT NULL,

  `product_image7_m_height` int(11) NOT NULL,

  `product_image8_name` varchar(255) NOT NULL,

  `product_image8_s_width` int(11) NOT NULL,

  `product_image8_s_height` int(11) NOT NULL,

  `product_image8_m_width` int(11) NOT NULL,

  `product_image8_m_height` int(11) NOT NULL,

  `product_description` varchar(255) NOT NULL,

 

Thanks,

Nick.

Link to comment
Share on other sites

Try creating your query like this:

<?php
$qtmp = array();
$qtmp[] = "cat_id = '" . $cat_id . "'";
$qtmp[] = "product_name = '" . $product_name . "'";
$qtmp[] = "product_slug = '" . Word2Slug($product_name) . "'";
for($i=0;$i<9;$i++) {
$qtmp[] = "product_image" . $i . "_name = '" . $product_image_name[$i] . "'";
$qtmp[] = "product_image" . $i . "_s_width = '" . $Image[$i]['small']['width'] . "'";
$qtmp[] = "product_image" . $i . "_s_height = '" . $Image[$i]['small']['height'] . "'";
$qtmp[] = "product_image" . $i . "_m_width = '" . $Image[$i]['medium']['width'] . "'";
$qtmp[] = "product_image" . $i . "_s_height = '" . $Image[$i]['medium']['height'] . "'";
}
$qtmp[] = "product_description = '" . $product_description "'";
$Query = "INSERT INTO `product_products` set " . implode(', ',$qtmp);
?>

 

See what happens.

 

Ken

Link to comment
Share on other sites

Grrr! Same again, it makes so little sense to me.  :-[

 

Thanks a lot for your time with that code kenrbnsn.

 

Here's the output:

 

MySQL Query - INSERT INTO `product_products` set cat_id = '27', product_name = '33333333', product_slug = '33333333', product_image0_name = '77684b9e3d5cb1547478f922f14ca875.jpg', product_image0_s_width = '65', product_image0_s_height = '49', product_image0_m_width = '245', product_image0_s_height = '184', product_image1_name = 'b7f102a5e21c844364f95170232b3cac.jpg', product_image1_s_width = '65', product_image1_s_height = '49', product_image1_m_width = '245', product_image1_s_height = '184', product_image2_name = 'bcb8fe9879f7a41ffa90bdb69a0b97e1.jpg', product_image2_s_width = '65', product_image2_s_height = '49', product_image2_m_width = '245', product_image2_s_height = '184', product_image3_name = '7773d2aac505ef263eca82e7cdbf5f49.jpg', product_image3_s_width = '65', product_image3_s_height = '49', product_image3_m_width = '245', product_image3_s_height = '184', product_image4_name = 'e729b0afe39636ca4dc9ff97f544e032.jpg', product_image4_s_width = '65', product_image4_s_height = '49', product_image4_m_width = '245', product_image4_s_height = '184', product_image5_name = 'e140af61a9c60c4b80984b8d3cc8b365.jpg', product_image5_s_width = '65', product_image5_s_height = '49', product_image5_m_width = '245', product_image5_s_height = '184', product_image6_name = 'a2e659a51207e186a05dbae9251224fc.jpg', product_image6_s_width = '65', product_image6_s_height = '49', product_image6_m_width = '245', product_image6_s_height = '184', product_image7_name = 'ca90a2dd1dbb570604f90dc5efe1b546.jpg', product_image7_s_width = '65', product_image7_s_height = '49', product_image7_m_width = '245', product_image7_s_height = '184', product_image8_name = 'f2dc09b17ae44d5788ba348c3e853573.jpg', product_image8_s_width = '65', product_image8_s_height = '49', product_image8_m_width = '245', product_image8_s_height = '184', product_description = '444444444'

The server returned the following message:

 

Unknown column 'product_image0_name' in 'field list'

Link to comment
Share on other sites

My error with cut/paste/replace, change:

<?php
$qtmp[] = "product_image" . $i . "_s_height = '" . $Image[$i]['medium']['height'] . "'";
?>

to

<?php
$qtmp[] = "product_image" . $i . "_m_height = '" . $Image[$i]['medium']['height'] . "'";
?>

 

Ken

Link to comment
Share on other sites

Thanks alot but still no luck unfortunately. :(

 

It outputs:

 

The following error occured whilst forming the following operation - Executing MySQL Query - INSERT INTO `product_products` set cat_id = '27', product_name = 'asdasdas', product_slug = 'asdasdas', product_image0_name = '7a4b9c37c2d8c7df1d70d1eb35a69895.jpg', product_image0_s_width = '65', product_image0_m_height = '184', product_image0_m_width = '245', product_image0_s_height = '184', product_image1_name = '75b7c9bf5a1088573dc7ffe8b31a741f.jpg', product_image1_s_width = '65', product_image1_m_height = '184', product_image1_m_width = '245', product_image1_s_height = '184', product_image2_name = '3ddd216f93d9b6f3f6def2319c3f1aab.jpg', product_image2_s_width = '65', product_image2_m_height = '184', product_image2_m_width = '245', product_image2_s_height = '184', product_image3_name = '57d9d77cfe5855ed6e5c861d850e3175.jpg', product_image3_s_width = '65', product_image3_m_height = '184', product_image3_m_width = '245', product_image3_s_height = '184', product_image4_name = '438004d73ba6e494fbd38c09054509d2.jpg', product_image4_s_width = '65', product_image4_m_height = '184', product_image4_m_width = '245', product_image4_s_height = '184', product_image5_name = '3ed2d816eef56ccc0c141e711d287e93.jpg', product_image5_s_width = '65', product_image5_m_height = '184', product_image5_m_width = '245', product_image5_s_height = '184', product_image6_name = '877465cdd961b2a2caa079b25002b3f2.jpg', product_image6_s_width = '65', product_image6_m_height = '184', product_image6_m_width = '245', product_image6_s_height = '184', product_image7_name = '40c62efb255476137dc14806c54516cb.jpg', product_image7_s_width = '65', product_image7_m_height = '184', product_image7_m_width = '245', product_image7_s_height = '184', product_image8_name = 'e225d6cdcbc0f816893c8e3451a2135c.jpg', product_image8_s_width = '65', product_image8_m_height = '184', product_image8_m_width = '245', product_image8_s_height = '184', product_description = 'asda'

The server returned the following message:

 

Unknown column 'product_image0_name' in 'field list'

 

 

Paste that into my SQL form in phpmyadmin and voila, it works fine?  ???

Link to comment
Share on other sites

your query is missing the auto increment field, i put that in and it worked 4 me.

 

$Query	=	"INSERT INTO `product_products`(
		`product_id`
                                      `cat_id`,
		`product_name`,
		`product_slug`,
		`product_image0_name`,
		`product_image0_s_width`,
		`product_image0_s_height`,
		`product_image0_m_width`,
		`product_image0_m_height`,
		`product_image1_name`,
		`product_image1_s_width`,
		`product_image1_s_height`,
		`product_image1_m_width`,
		`product_image1_m_height`,
		`product_image2_name`,
		`product_image2_s_width`,
		`product_image2_s_height`,
		`product_image2_m_width`,
		`product_image2_m_height`,
		`product_image3_name`,
		`product_image3_s_width`,
		`product_image3_s_height`,
		`product_image3_m_width`,
		`product_image3_m_height`,
		`product_image4_name`,
		`product_image4_s_width`,
		`product_image4_s_height`,
		`product_image4_m_width`,
		`product_image4_m_height`,
		`product_image5_name`,
		`product_image5_s_width`,
		`product_image5_s_height`,
		`product_image5_m_width`,
		`product_image5_m_height`,
		`product_image6_name`,
		`product_image6_s_width`,
		`product_image6_s_height`,
		`product_image6_m_width`,
		`product_image6_m_height`,
		`product_image7_name`,
		`product_image7_s_width`,
		`product_image7_s_height`,
		`product_image7_m_width`,
		`product_image7_m_height`,
		`product_image8_name`,
		`product_image8_s_width`,
		`product_image8_s_height`,
		`product_image8_m_width`,
		`product_image8_m_height`,
		`product_description`) 
		VALUES (
                                       '',
		'$cat_id',
		'$product_name',
		'".Word2Slug($product_name)."',
		'".$product_image_name[0]."',
		'".$Image[0]['small']['width']."',
		'".$Image[0]['small']['height']."',
		'".$Image[0]['medium']['width']."',
		'".$Image[0]['medium']['height']."',
		'".$product_image_name[1]."',
		'".$Image[1]['small']['width']."',
		'".$Image[1]['small']['height']."',
		'".$Image[1]['medium']['width']."',
		'".$Image[1]['medium']['height']."',
		'".$product_image_name[2]."',
		'".$Image[2]['small']['width']."',
		'".$Image[2]['small']['height']."',
		'".$Image[2]['medium']['width']."',
		'".$Image[2]['medium']['height']."',
		'".$product_image_name[3]."',
		'".$Image[3]['small']['width']."',
		'".$Image[3]['small']['height']."',
		'".$Image[3]['medium']['width']."',
		'".$Image[3]['medium']['height']."',
		'".$product_image_name[4]."',
		'".$Image[4]['small']['width']."',
		'".$Image[4]['small']['height']."',
		'".$Image[4]['medium']['width']."',
		'".$Image[4]['medium']['height']."',
		'".$product_image_name[5]."',
		'".$Image[5]['small']['width']."',
		'".$Image[5]['small']['height']."',
		'".$Image[5]['medium']['width']."',
		'".$Image[5]['medium']['height']."',
		'".$product_image_name[6]."',
		'".$Image[6]['small']['width']."',
		'".$Image[6]['small']['height']."',
		'".$Image[6]['medium']['width']."',
		'".$Image[6]['medium']['height']."',
		'".$product_image_name[7]."',
		'".$Image[7]['small']['width']."',
		'".$Image[7]['small']['height']."',
		'".$Image[7]['medium']['width']."',
		'".$Image[7]['medium']['height']."',
		'".$product_image_name[8]."',
		'".$Image[8]['small']['width']."',
		'".$Image[8]['small']['height']."',
		'".$Image[8]['medium']['width']."',
		'".$Image[8]['medium']['height']."',
		'$product_description')";

Link to comment
Share on other sites

Sorry I should know that, but it works absoloutly perfectly for me, anouther stupid question you are using mysql(dont think phpmyadmin do anything else) ? which version are you using.

 

alos heres my code to test your query.

 

<?
  $dbserver = "127.0.0.1";
  $dbusername = "********";
  $dbpassword = "*****";  
  $dbname ="******************";
  $link=mysql_connect ($dbserver,$dbusername,$dbpassword) or die ('DB ERROR -> ' . mysql_error());
  mysql_select_db ($dbname); 

  function q($query,$assoc=1)
  {
   $r = @mysql_query($query);
   if( mysql_errno() ) {
       $error = 'MYSQL ERROR #'.mysql_errno().' : <small>' . mysql_error(). '</small><br><VAR>$query</VAR>';
       echo($error); return FALSE;
   } 
   if( strtolower(substr($query,0,6)) != 'select' ) return array(mysql_affected_rows(),mysql_insert_id());
   $count = @mysql_num_rows($r);
   if( !$count ) return 0;
   if( $count == 1 ) {
       if( $assoc ) $f = mysql_fetch_assoc($r);
       else $f = mysql_fetch_row($r);
       mysql_free_result($r);
       if( count($f) == 1 ) {
           list($key) = array_keys($f);    
           return $f[$key];
       } else {
           $all = array();
           $all[] = $f;
           return $all;
       }
   } else {
       $all = array();
       for( $i = 0; $i < $count; $i++ ) {
           if( $assoc ) $f = mysql_fetch_assoc($r);
           else $f = mysql_fetch_row($r);
           $all[] = $f;
       }
       mysql_free_result($r);
       return $all;
    }
  }
  for($i=0;$i<=8;$i++){$Image[$i]['small']['width']=1;$Image[$i]['small']['height']=1;$Image[$i]['medium']['width']=1;$Image[$i]['medium']['height']=1;$product_image_name[$i]="bob".$i;$product_name=$i."bobbys";$product_description="frogs";$cat_id=12;}
$Query	=	"INSERT INTO `products_products`(
		`cat_id`,
		`product_name`,
		`product_slug`,
		`product_image0_name`,
		`product_image0_s_width`,
		`product_image0_s_height`,
		`product_image0_m_width`,
		`product_image0_m_height`,
		`product_image1_name`,
		`product_image1_s_width`,
		`product_image1_s_height`,
		`product_image1_m_width`,
		`product_image1_m_height`,
		`product_image2_name`,
		`product_image2_s_width`,
		`product_image2_s_height`,
		`product_image2_m_width`,
		`product_image2_m_height`,
		`product_image3_name`,
		`product_image3_s_width`,
		`product_image3_s_height`,
		`product_image3_m_width`,
		`product_image3_m_height`,
		`product_image4_name`,
		`product_image4_s_width`,
		`product_image4_s_height`,
		`product_image4_m_width`,
		`product_image4_m_height`,
		`product_image5_name`,
		`product_image5_s_width`,
		`product_image5_s_height`,
		`product_image5_m_width`,
		`product_image5_m_height`,
		`product_image6_name`,
		`product_image6_s_width`,
		`product_image6_s_height`,
		`product_image6_m_width`,
		`product_image6_m_height`,
		`product_image7_name`,
		`product_image7_s_width`,
		`product_image7_s_height`,
		`product_image7_m_width`,
		`product_image7_m_height`,
		`product_image8_name`,
		`product_image8_s_width`,
		`product_image8_s_height`,
		`product_image8_m_width`,
		`product_image8_m_height`,
		`product_description`) 
		VALUES (
		'$cat_id',
		'$product_name',
		'".$product_name."',
		'".$product_image_name[0]."',
		'".$Image[0]['small']['width']."',
		'".$Image[0]['small']['height']."',
		'".$Image[0]['medium']['width']."',
		'".$Image[0]['medium']['height']."',
		'".$product_image_name[1]."',
		'".$Image[1]['small']['width']."',
		'".$Image[1]['small']['height']."',
		'".$Image[1]['medium']['width']."',
		'".$Image[1]['medium']['height']."',
		'".$product_image_name[2]."',
		'".$Image[2]['small']['width']."',
		'".$Image[2]['small']['height']."',
		'".$Image[2]['medium']['width']."',
		'".$Image[2]['medium']['height']."',
		'".$product_image_name[3]."',
		'".$Image[3]['small']['width']."',
		'".$Image[3]['small']['height']."',
		'".$Image[3]['medium']['width']."',
		'".$Image[3]['medium']['height']."',
		'".$product_image_name[4]."',
		'".$Image[4]['small']['width']."',
		'".$Image[4]['small']['height']."',
		'".$Image[4]['medium']['width']."',
		'".$Image[4]['medium']['height']."',
		'".$product_image_name[5]."',
		'".$Image[5]['small']['width']."',
		'".$Image[5]['small']['height']."',
		'".$Image[5]['medium']['width']."',
		'".$Image[5]['medium']['height']."',
		'".$product_image_name[6]."',
		'".$Image[6]['small']['width']."',
		'".$Image[6]['small']['height']."',
		'".$Image[6]['medium']['width']."',
		'".$Image[6]['medium']['height']."',
		'".$product_image_name[7]."',
		'".$Image[7]['small']['width']."',
		'".$Image[7]['small']['height']."',
		'".$Image[7]['medium']['width']."',
		'".$Image[7]['medium']['height']."',
		'".$product_image_name[8]."',
		'".$Image[8]['small']['width']."',
		'".$Image[8]['small']['height']."',
		'".$Image[8]['medium']['width']."',
		'".$Image[8]['medium']['height']."',
		'$product_description')";
		if(q($Query)){echo "QUERY EXECUTED CORRECTLY";}else{echo "QUERY ERROR";}
?>

Link to comment
Share on other sites

SQL is v5.0.67 I think and yes I'm using MyISAM.

 

Here is the table SQL:

 

CREATE TABLE IF NOT EXISTS `product_products` (
  `product_id` int(11) NOT NULL auto_increment,
  `cat_id` int(11) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `product_slug` varchar(255) NOT NULL,
  `product_image0_name` varchar(255) NOT NULL,
  `product_image0_s_width` int(11) NOT NULL,
  `product_image0_s_height` int(11) NOT NULL,
  `product_image0_m_width` int(11) NOT NULL,
  `product_image0_m_height` int(11) NOT NULL,
  `product_image1_name` varchar(255) NOT NULL,
  `product_image1_s_width` int(11) NOT NULL,
  `product_image1_s_height` int(11) NOT NULL,
  `product_image1_m_width` int(11) NOT NULL,
  `product_image1_m_height` int(11) NOT NULL,
  `product_image2_name` varchar(255) NOT NULL,
  `product_image2_s_width` int(11) NOT NULL,
  `product_image2_s_height` int(11) NOT NULL,
  `product_image2_m_width` int(11) NOT NULL,
  `product_image2_m_height` int(11) NOT NULL,
  `product_image3_name` varchar(255) NOT NULL,
  `product_image3_s_width` int(11) NOT NULL,
  `product_image3_s_height` int(11) NOT NULL,
  `product_image3_m_width` int(11) NOT NULL,
  `product_image3_m_height` int(11) NOT NULL,
  `product_image4_name` varchar(255) NOT NULL,
  `product_image4_s_width` int(11) NOT NULL,
  `product_image4_s_height` int(11) NOT NULL,
  `product_image4_m_width` int(11) NOT NULL,
  `product_image4_m_height` int(11) NOT NULL,
  `product_image5_name` varchar(255) NOT NULL,
  `product_image5_s_width` int(11) NOT NULL,
  `product_image5_s_height` int(11) NOT NULL,
  `product_image5_m_width` int(11) NOT NULL,
  `product_image5_m_height` int(11) NOT NULL,
  `product_image6_name` varchar(255) NOT NULL,
  `product_image6_s_width` int(11) NOT NULL,
  `product_image6_s_height` int(11) NOT NULL,
  `product_image6_m_width` int(11) NOT NULL,
  `product_image6_m_height` int(11) NOT NULL,
  `product_image7_name` varchar(255) NOT NULL,
  `product_image7_s_width` int(11) NOT NULL,
  `product_image7_s_height` int(11) NOT NULL,
  `product_image7_m_width` int(11) NOT NULL,
  `product_image7_m_height` int(11) NOT NULL,
  `product_image8_name` varchar(255) NOT NULL,
  `product_image8_s_width` int(11) NOT NULL,
  `product_image8_s_height` int(11) NOT NULL,
  `product_image8_m_width` int(11) NOT NULL,
  `product_image8_m_height` int(11) NOT NULL,
  `product_description` varchar(255) NOT NULL,
  PRIMARY KEY  (`product_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=50 ;

 

I've also attached the PHP file that does the uploading with this script in.

 

Hopefully you can figure out what it could be?

 

I really appreciate your help.

 

Regards,

Nick.

 

[attachment deleted by admin]

Link to comment
Share on other sites

I dont have the extensions you have obviously so i just commeted them out, but uploads without error

<?php
session_start();
error_reporting(E_ALL);
// Variables
//-----------------------------------------------------------------------------------------------------------

// DATABASE CONNECTIVITY
//-----------------------------------------------------------------------------------------------------------
  $dbserver = "127.0.0.1";
  $dbusername = "*******";
  $dbpassword = "*******";  
  $dbname ="********";
  $link=mysql_connect ($dbserver,$dbusername,$dbpassword) or die ('DB ERROR -> ' . mysql_error());
  mysql_select_db ($dbname); 
/* mysql table
CREATE TABLE `webdesig_upload`.`tbl_files` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`filename` TEXT NOT NULL ,
`path` TEXT NOT NULL ,
`size` INT NOT NULL ,
`ext` VARCHAR( 5 ) NOT NULL ,
`date` INT NOT NULL ,
`time` INT NOT NULL ,
`viewed` TINYINT NOT NULL DEFAULT '0',
`downloaded` TINYINT NOT NULL DEFAULT '0',
`locked` TINYINT NOT NULL DEFAULT '0'
) ENGINE = MYISAM 
*/
//---------------------------------------------------------------------------------------------------------
// FUNCTIONS AND CLASSES etc  
  function q($query,$assoc=1)
  {
   $r = @mysql_query($query);
   if( mysql_errno() ) {
       $error = 'MYSQL ERROR #'.mysql_errno().' : <small>' . mysql_error(). '</small><br><VAR>$query</VAR>';
       echo($error); return FALSE;
   } 
   if( strtolower(substr($query,0,6)) != 'select' ) return array(mysql_affected_rows(),mysql_insert_id());
   $count = @mysql_num_rows($r);
   if( !$count ) return 0;
   if( $count == 1 ) {
       if( $assoc ) $f = mysql_fetch_assoc($r);
       else $f = mysql_fetch_row($r);
       mysql_free_result($r);
       if( count($f) == 1 ) {
           list($key) = array_keys($f);    
           return $f[$key];
       } else {
           $all = array();
           $all[] = $f;
           return $all;
       }
   } else {
       $all = array();
       for( $i = 0; $i < $count; $i++ ) {
           if( $assoc ) $f = mysql_fetch_assoc($r);
           else $f = mysql_fetch_row($r);
           $all[] = $f;
       }
       mysql_free_result($r);
       return $all;
    }
  }

?> <h2>Add Product</h2><? 
    if(isset($_POST['action']) && $_POST['action']	==	'add_product'){
//Product Variables
$cat_id	=	$_POST['cat_id'];
$product_name	=	$_POST['product_name'];

//main image
$product_image[0]	=	$_FILES['product_image0'];
//closeup images
$product_image[1]	=	$_FILES['product_image1'];
$product_image[2]	=	$_FILES['product_image2'];
$product_image[3]	=	$_FILES['product_image3'];
$product_image[4]	=	$_FILES['product_image4'];
$product_image[5]	=	$_FILES['product_image5'];
$product_image[6]	=	$_FILES['product_image6'];
$product_image[7]	=	$_FILES['product_image7'];
$product_image[8]	=	$_FILES['product_image8'];

$product_description	=	$_POST['product_description'];
//Image Types
$AllowedImages	=	array('image/jpeg','image/pjpeg');

//Preverification of image filetypes
for ($i=0; $i<count($product_image); $i++){
	if (in_array($product_image[$i]['type'], $AllowedImages)){
		$product_image_allowed = 1; //current image type is allowed
	}
	else {
		$product_image_allowed = 0; //current image type is not allowed
		break; //found an image type that's denied - quit the loop
	}
}

//Verification

if(!empty($cat_id) && !empty($product_name) && !empty($product_description) && $product_image['error'] == 0 && $product_image_allowed == 1){
	//Continue & Add to DB
/*	
	//process the images
	for ($i=0; $i<count($product_image); $i++){
		$product_image_name[$i] = md5(microtime()).'.jpg'; //generate the filename
	if($product_image[$i]['error'] != 0)
die('Error on Upload: '. $product_image[$i]['error']);
		//Write Original File
		//WriteFile($cfg['productimages']['original']['folder'].$product_image_name[$i], file_get_contents($product_image[$i]['tmp_name']));
		//Create medium sized thumbnail
		$ImageFunctions->Open($cfg['productimages']['original']['folder'].$product_image_name[$i]);
		$ImageFunctions->Resize(245,184);
		$ImageFunctions->RawOutput();
		WriteFile($cfg['productimages']['medium']['folder'].$product_image_name[$i], $ImageFunctions->Output['Content']);
			//Get Dimensions
			$Image[$i]['medium']['width']	=	$ImageFunctions->Width;
			$Image[$i]['medium']['height']	=	$ImageFunctions->Height;
		//Create smaill sized thumbnail
		$ImageFunctions->Open($cfg['productimages']['original']['folder'].$product_image_name[$i]);
		$ImageFunctions->Resize(65,49);
		$ImageFunctions->RawOutput();
		//WriteFile($cfg['productimages']['small']['folder'].$product_image_name[$i], $ImageFunctions->Output['Content']);
			//Get Dimensions
			$Image[$i]['small']['width']	=	$ImageFunctions->Width;
			$Image[$i]['small']['height']	=	$ImageFunctions->Height;
		//End Image Processing
	}*/
	for($i=0;$i<=8;$i++){$Image[$i]['small']['width']=1;$Image[$i]['small']['height']=1;$Image[$i]['medium']['width']=1;$Image[$i]['medium']['height']=1;$product_image_name[$i]="bob".$i;$product_name=$i."bobbys";$product_description="frogs";$cat_id=12;}
$Query   =   "INSERT INTO `product_products`(
         `product_id`,
	  `cat_id`,
         `product_name`,
         `product_slug`,
         `product_image0_name`,
         `product_image0_s_width`,
         `product_image0_s_height`,
         `product_image0_m_width`,
         `product_image0_m_height`,
         `product_image1_name`,
         `product_image1_s_width`,
         `product_image1_s_height`,
         `product_image1_m_width`,
         `product_image1_m_height`,
         `product_image2_name`,
         `product_image2_s_width`,
         `product_image2_s_height`,
         `product_image2_m_width`,
         `product_image2_m_height`,
         `product_image3_name`,
         `product_image3_s_width`,
         `product_image3_s_height`,
         `product_image3_m_width`,
         `product_image3_m_height`,
         `product_image4_name`,
         `product_image4_s_width`,
         `product_image4_s_height`,
         `product_image4_m_width`,
         `product_image4_m_height`,
         `product_image5_name`,
         `product_image5_s_width`,
         `product_image5_s_height`,
         `product_image5_m_width`,
         `product_image5_m_height`,
         `product_image6_name`,
         `product_image6_s_width`,
         `product_image6_s_height`,
         `product_image6_m_width`,
         `product_image6_m_height`,
         `product_image7_name`,
         `product_image7_s_width`,
         `product_image7_s_height`,
         `product_image7_m_width`,
         `product_image7_m_height`,
         `product_image8_name`,
         `product_image8_s_width`,
         `product_image8_s_height`,
         `product_image8_m_width`,
         `product_image8_m_height`,
         `product_description`)
         VALUES (
                                       '',
         '$cat_id',
         '$product_name',
         '".$product_name."',
         '".$product_image_name[0]."',
         '".$Image[0]['small']['width']."',
         '".$Image[0]['small']['height']."',
         '".$Image[0]['medium']['width']."',
         '".$Image[0]['medium']['height']."',
         '".$product_image_name[1]."',
         '".$Image[1]['small']['width']."',
         '".$Image[1]['small']['height']."',
         '".$Image[1]['medium']['width']."',
         '".$Image[1]['medium']['height']."',
         '".$product_image_name[2]."',
         '".$Image[2]['small']['width']."',
         '".$Image[2]['small']['height']."',
         '".$Image[2]['medium']['width']."',
         '".$Image[2]['medium']['height']."',
         '".$product_image_name[3]."',
         '".$Image[3]['small']['width']."',
         '".$Image[3]['small']['height']."',
         '".$Image[3]['medium']['width']."',
         '".$Image[3]['medium']['height']."',
         '".$product_image_name[4]."',
         '".$Image[4]['small']['width']."',
         '".$Image[4]['small']['height']."',
         '".$Image[4]['medium']['width']."',
         '".$Image[4]['medium']['height']."',
         '".$product_image_name[5]."',
         '".$Image[5]['small']['width']."',
         '".$Image[5]['small']['height']."',
         '".$Image[5]['medium']['width']."',
         '".$Image[5]['medium']['height']."',
         '".$product_image_name[6]."',
         '".$Image[6]['small']['width']."',
         '".$Image[6]['small']['height']."',
         '".$Image[6]['medium']['width']."',
         '".$Image[6]['medium']['height']."',
         '".$product_image_name[7]."',
         '".$Image[7]['small']['width']."',
         '".$Image[7]['small']['height']."',
         '".$Image[7]['medium']['width']."',
         '".$Image[7]['medium']['height']."',
         '".$product_image_name[8]."',
         '".$Image[8]['small']['width']."',
         '".$Image[8]['small']['height']."',
         '".$Image[8]['medium']['width']."',
         '".$Image[8]['medium']['height']."',
         '$product_description')";

	q($Query);
	echo $Query;

	echo '<p>Product Added.</p>';
} else{
	echo '<p>Please ensure that you have filled in all fields correctly, and you have tried to upload a JPEG image.</p>';
}
}
?>

<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="add_product" />
<p>Category: 
<select name="cat_id">
<?php
$Query	=	"SELECT * FROM `product_cats` ORDER BY `cat_name` ASC";
$Rows	=	q($Query);
if($Rows	==	0){
echo '<option disabled="disabled" value="stop">No Categories Found</option>';
} else{
$Result	=	q($Query);
for($i=0;$i<$Rows;$i++){
	echo '<option value="'.$Db->Result($Result, $i, 'cat_id').'">'.$Db->Result($Result, $i, 'cat_name').'</option>';

}
}
?>
</select>
</p>
<p>Product Name: <input type="text" name="product_name" /></p>
<p>Product Image (main) (Jpeg Only): <input type="file" name="product_image0" /></p>
<p>Closeup Image 1 (Jpeg Only): <input type="file" name="product_image1" /></p>
<p>Closeup Image 2 (Jpeg Only): <input type="file" name="product_image2" /></p>
<p>Closeup Image 3 (Jpeg Only): <input type="file" name="product_image3" /></p>
<p>Closeup Image 4 (Jpeg Only): <input type="file" name="product_image4" /></p>
<p>Closeup Image 5 (Jpeg Only): <input type="file" name="product_image5" /></p>
<p>Closeup Image 6 (Jpeg Only): <input type="file" name="product_image6" /></p>
<p>Closeup Image 7 (Jpeg Only): <input type="file" name="product_image7" /></p>
<p>Closeup Image 8 (Jpeg Only): <input type="file" name="product_image8" /></p>
<p>Product Description:</p>
<p><textarea name="product_description" style="width:500px;height:250px;font-family:Arial, Helvetica, sans-serif;"></textarea></p>
<p><input type="submit" value="Add Product" /></p>
</form>

Link to comment
Share on other sites

Hmm, don't think so but here are my functions:

 

<?php

	//MySQL Query Function
	function Query($Query = NULL){
		$Return = @mysql_query($Query, $this->conn) or $this->Error(mysql_error(),'Executing MySQL Query - '.$Query);
		//Increase number of queries
			$this->Queries++;
		//Set last query
			$this->LastQuery = $Query;
		//Insert query into Query List
			array_push($this->QueryList, $Query);
		return $Return;
	} //End Query()

	//MySQL Fetch Array Function
	function FetchArray($Query = NULL){
		$Query = $this->Query($Query);
		$Array = @mysql_fetch_assoc($Query) or $this->Error(mysql_error(),'Fetching data array using - '.$Query);
		return $Array;
	} //End Fetch_Array

	//Function to return MySQL Numrows
	function Rows($Query = NULL){
		//If empty then use query in cache
		if(empty($Query)){
			$Query = $this->Query;
		} else{
			$Query = $this->Query($Query);
		}
		$Rows = @mysql_numrows($Query);
		return $Rows;
	} //End Rows()

	//MySQL Result Function
	function Result($Query, $Row, $Field){
		//Return Filed Valie
		$return = @mysql_result($Query, $Row, $Field);
		return $return;
	}//End Result()

	//Output list of queries to the browser
	function QueryList(){
	//Only execute if debug mode is on
		if($this->DebugMode){
			echo '<table>';
			echo '<tr><td>';
			echo 'Query ID';
			echo '</td><td>';
			echo 'Query';
			echo '</td></tr>';
			//Loop through all query's stored
			foreach($this->QueryList as $id => $qry){
				echo '<tr><td>';
				echo $id;
				echo '</td><td>';
				echo $qry;
				echo '</td></tr>';
			}
			echo '</table>';
		}
	}//End QueryList()

	//Function to Display Error Message
	function Error($MySQL_Error,$Notes){
		if($this->DebugMode){
			echo 'The following error occured whilst forming the following operation - ';
			echo $Notes;
			echo '<br />';
			echo 'The server returned the following message:';
			echo '<br /><br />';
			echo $MySQL_Error;
			exit;
		} else{
			die($this->ErrorMessage);
		}
	} //End Error()
};
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.