text and binary file into mysql

wxdqz

New Member
I have a question that I'm hoping someone can help with.

my script is a simple form to mysql table input (all text data) this works correctly. The problem is that when I add the lines to put a binary file in the same database table I get parse errors.

the syntax works correctly when just inserting a binary file in a table. Is it not possible to insert text into some fields in a table and binary files into others all from the same form..See the problem code..

<?
if ((!$company)) { header("Location: <!-- m --><a class="postlink" href="https://www2.mysite.com/infoform.htm">https://www2.mysite.com/infoform.htm</a><!-- m -->");
exit;
}
$db_name = "mydb";
$table_name = "customer";
$connection = mysql_connect("localhost", "root") or die ("couldn't connect");
$db = mysql_select_db($db_name, $connection) or die ("Couldn't select db");

$binfile = addslashes (fread(fopen($file1, "r"), filesize($file1)));

$sql = "

INSERT INTO $table_name
(ciid,
company,
contact_name,
contact_email,
cust_phone,
cust_fax,
ph_add1,
ph_add2,
ph_city,
ph_st,
ph_zip,
site_file,
filetype,
filename,
filesize)

VALUES
(\"\",
\"$company\",
\"$contact_name\",
\"$contact_email\",
\"$cust_phone\",
\"$cust_fax\",
\"$ph_add1\",
\"$ph_add2\",
\"$ph_city\",
\"$ph_st\",
\"$ph_zip\",
\"$binfile\",
\"$file1_size\"
\"$file1_name\"
\"$file1_type\")
";

$result = mysql_query($sql,$connection) or die ("couldnt execute query");

?>


<HEAD>
<TITLE>Successful File Insertion!</TITLE>
<BODY>

<H1>Success!</H1>

</P>

</BODY>
 
Back
Top