Hi Brad,
Apologies, I obviously missed (or likely didn't understand) the solution. As far as I could gather djjjozsi gave me the mres function that would handle empty variables. Then told me to escape strings to combat the problem with inserting quotes into the database?
I escaped the strings, but instead of inserting the entire escaped string into the database it simply cuts the string off when it comes to a quote. A further more perplexing problem is that it only does this on my scripts that insert information into the database, where it is updating an existing record then the quotation marks (and any other escaped characters) are succesfully inserted.
However, when it is a script that inserts a new record. I am presented with the ,aforementioned, problem of the string being cut off at the first escaped character.
The code for the update script 'that works' is;
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$code = mysql_real_escape_string($code, $con);
$name = mysql_real_escape_string($name, $con);
$price = mysql_real_escape_string($price, $con);
$description = mysql_real_escape_string($description, $con);
$material = mysql_real_escape_string($material, $con);
$etsy = mysql_real_escape_string($etsy, $con);
$sql="UPDATE products SET product_code='$code', product_name='$name', price='$price', product_description='$description', product_collection='$collection', product_category='$category', product_material='$material', etsy_link='$etsy', product_picture='$picture', product_thumbnail='$thumbnail' WHERE product_id='$id'";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con);
The code for the insert script that 'isn't working' is;
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$code = mysql_real_escape_string($code, $con);
$name = mysql_real_escape_string($name, $con);
$price = mysql_real_escape_string($price, $con);
$description = mysql_real_escape_string($description, $con);
$material = mysql_real_escape_string($material, $con);
$etsy = mysql_real_escape_string($etsy, $con);
$sql="INSERT INTO products (product_code,product_name, price, product_description, product_collection, product_category, product_picture, product_thumbnail, product_material, etsy_link)
VALUES
('$code','$name','$price','$description','$collection','$category','$file','$file_thumb','$material','$etsy')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con);
Apologies again if this has already been explained, but it is somewhat perplexing me.
As always, I'm extremely grateful for the help,