i'm trying to insert a blob into my table, it will insert but the string that i insert when i query the inserted data returns null with 0 bytes in the column.
I have other tables set up this way and i'm able to insert text data into it with no problems. I've checked the database design its basiclly a duplicate. I did have to remove my not null on the long blob element.
but other then that, i don't understand why this is capturing a null value.
Thanks, in advance for your help.
Expand|Select|Wrap|Line Numbers
- <?php
- if (!function_exists("GetSQLValueString")) {
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
- {
- if (PHP_VERSION < 6) {
- $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
- }
- $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
- switch ($theType) {
- case "text":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "long":
- case "int":
- $theValue = ($theValue != "") ? intval($theValue) : "NULL";
- break;
- case "double":
- $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
- break;
- case "date":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "defined":
- $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
- break;
- }
- return $theValue;
- }
- }
- $editFormAction = $_SERVER['PHP_SELF'];
- if (isset($_SERVER['QUERY_STRING'])) {
- $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
- }
- $IPA = $_SERVER['REMOTE_ADDR'] ;
- $DOM ="o1w" ;
- //$DT = 'now()' ;
- if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
- $insertSQL0 = sprintf("INSERT INTO domain (Id, doms_Id, Dt, Domain, IpAddress) VALUES (%s, %s, now(), '$DOM', '$IPA')",
- GetSQLValueString($_POST['Id'], "int"),
- GetSQLValueString($_POST['doms_Id'], "int"),
- GetSQLValueString($_POST['Dt'], "date"),
- GetSQLValueString($_POST['Domain'], "text"),
- GetSQLValueString($_POST['IpAddress'], "text"));
- // eula schema
- $insertSQL1 = sprintf("insert into eos (Id_fk, Id, Eula, Dt, Domain, IpAddress) values (last_insert_id(), last_insert_id(), AES_ENCRYPT(%s, '$userpass'), now(), '$DOM', '$IPA')",
- GetSQLValueString($_POST['Id_fk'], "int"),
- GetSQLValueString($_POST['Id'], "int"),
- GetSQLValueString($_POST['Eula'], "text"),
- GetSQLValueString($_POST['Dt'], "date"),
- GetSQLValueString($_POST['Domain'], "text"),
- GetSQLValueString($_POST['IpAddress'], "text"));
- //tos schema
- $insertSQL2 = sprintf("insert into tos (Id_fk, Id, TOS, Dt, Domain, IpAddress) values (last_insert_id(), last_insert_id(), AES_ENCRYPT(%s, '$userpass'), now(), '$DOM', '$IPA')",
- GetSQLValueString($_POST['Id_fk'], "int"),
- GetSQLValueString($_POST['Id'], "int"),
- GetSQLValueString($_POST['TOS'], "text"),
- GetSQLValueString($_POST['Dt'], "date"),
- GetSQLValueString($_POST['Domain'], "text"),
- GetSQLValueString($_POST['IpAddress'], "text"));
- mysql_select_db($database_user, $user);
- $Result0 = mysql_query($insertSQL0, $user) or die(mysql_error());
- mysql_select_db($database_user, $user);
- $Result1 = mysql_query($insertSQL1, $user) or die(mysql_error());
- mysql_select_db($database_user, $user);
- $Result2 = mysql_query($insertSQL2, $user) or die(mysql_error());
- }
- mysql_select_db($database_user, $user);
- $query_Recordset1 = "SELECT * FROM user";
- $Recordset1 = mysql_query($query_Recordset1, $user) or die(mysql_error());
- $row_Recordset1 = mysql_fetch_assoc($Recordset1);
- $totalRows_Recordset1 = mysql_num_rows($Recordset1);
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body>
- <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
- <table align="center">
- <tr valign="baseline">
- <td nowrap="nowrap" align="right">Id:</td>
- <td><select name="doms_Id">
- <?php
- do {
- ?>
- <option value="<?php echo $row_Recordset1['doms_Id']?>" ><?php echo $row_Recordset1['Domain_Name']?></option>
- <?php
- } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
- ?>
- </select></td>
- </tr>
- <tr> </tr>
- <tr valign="baseline">
- <td height="23" align="right" nowrap="nowrap">EULA:</td>
- <td><input type="text" name="Eula" value="" size="32" /></td>
- </tr>
- <tr valign="baseline">
- <td height="45" align="right" nowrap="nowrap">TOS:</td>
- <td><input type="text" name="TOS" value="" size="32" /></td>
- </tr>
- <tr valign="baseline">
- <td nowrap="nowrap" align="right"> </td>
- <td><input type="submit" value="Insert record" /></td>
- </tr>
- </table>
- <input type="hidden" name="Id" value="" />
- <input type="hidden" name="Dt" value="" />
- <input type="hidden" name="Domain" value="" />
- <input type="hidden" name="IpAddress" value="" />
- <input type="hidden" name="MM_insert" value="form1" />
- </form>
- <p> </p>
- </body>
- </html>
- <?php
- mysql_free_result($Recordset1);
- ?>