SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    685
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unexpected T_VARIABLE

    I'm getting Parse error: syntax error, unexpected T_VARIABLE error for the following. Can anyone help me sport the unexpected t_variable?

    PHP Code:
    mysql_query("INSERT INTO product (product_id, model, sku, upc, quantity, stock_status_id, manufacturer_id, shipping, price, points, tax_class_id, weight, weight_class_id, length, width, height, length_class_id, subtract, minimum, sort_order, status, date_added, date_modified, viewed) VALUES ("$row[productid]", "$row[product]", "$row[productcode]", "$row[UPC]", "$row[avail]", "7", "$row[manufactureid]", "1", "0.0000", "0", "9", "$row[weight]", "2", "0.00", "0.00", "0.00", "3", "1", "$row[min_amount]", "0", "1", "$row[add_date]", "$row[add_date]", "0")") or die(mysql_error()); 

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2011
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dump the double quotes from around your values:
    "$row[productid]"
    try just $row[productid]... same for all other VALUES

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    70
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Try this. I removed the double quotes on the $row[] variables and single quoted the array keys. Also I surrounded each $row with {} and according the netbeans the syntax error is gone. Also All the single string values are single quoted.

    In you code you had all the double quotes inside the string unescaped so it was causing it to enter and leave the string without the " . " operator to concatenate the string.

    PHP Code:
    $sql "INSERT INTO product (product_id, model, sku, upc, quantity, stock_status_id, manufacturer_id, shipping, price, points, tax_class_id, weight, weight_class_id, length, width, height, length_class_id, subtract, minimum, sort_order, status, date_added, date_modified, viewed)";
    $sql .= " VALUES ({$row['productid']}{$row['product']}{$row['productcode']}{$row['UPC']}{$row['avail']}, '7', {$row['manufactureid']}, '1', '0.0000', '0', '9', {$row['weight']}, '2', '0.00', '0.00', '0.00', '3', '1', {$row['min_amount']}, '0', '1', {$row['add_date']}{$row['add_date']}, '0')";
    mysql_query$sql ) or die( mysql_error() ); 

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    One more way to reinforce what ultra1 and Jeremy said:
    Code:
    mysql_query("
    	INSERT
    		INTO
    	product (
    	  product_id
    	, model
    	, sku
    	, upc
    	, quantity
    	, stock_status_id
    	, manufacturer_id
    	, shipping, price
    	, points
    	, tax_class_id
    	, weight
    	, weight_class_id
    	, length
    	, width
    	, height
    	, length_class_id
    	, subtract
    	, minimum
    	, sort_order
    	, status
    	, date_added
    	, date_modified
    	, viewed
    	) VALUES (
    	  '". $row['productid'] ."'
    	, '". $$row['product'] ."'
    	, '". $row['productcode'] ."'
    	, '". $row['UPC'] ."'
    	, '". $row['avail'] ."'
    	, '7'
    	, '". $row['manufactureid'] ."'
    	, '1'
    	, '0.0000'
    	, '0'
    	, '9'
    	, '". $row['weight'] ."'
    	, '2'
    	, '0.00'
    	, '0.00'
    	, '0.00'
    	, '3'
    	, '1'
    	, '" . $row['min_amount'] ."'
    	, '0'
    	, '1'
    	, '". $row['add_date'] ."'
    	, '". $row['add_date'] ."'
    	, '0'
    	)
    	") or die(mysql_error());
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •