problem with insert into mysql DB using PHP

Posted by user504363 on Stack Overflow See other posts from Stack Overflow or by user504363
Published on 2011-01-16T00:20:42Z Indexed on 2011/01/16 7:53 UTC
Read the original article Hit count: 218

Filed under:
|

Hi all

I have strange problem that I have a PHP page used to insert data into Mysql DB. the problem is that when I execute the code, nothing added to db and no errors is appeared although I set display errors codes

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

any idea about this problem !

here is my used code for inserting

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;
}


include("Connections/mzk_mdc.php");
                $ext = 1;
                $website = "mzk";
                $mzk_sql=sprintf("INSERT INTO downloads (image, `by`, `rapid_title`, title, `description`, category, div_id, topic_url, down_times, ext, `website`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                    GetSQLValueString($topic_thumb_image, "text"),
                     GetSQLValueString($topic_by, "text"),
                       GetSQLValueString($topic_des, "text"),
                       GetSQLValueString($topic_title, "text"),
                     GetSQLValueString($forum_content, "text"),
                     GetSQLValueString($topic_category, "text"),GetSQLValueString($topic_div, "text"),GetSQLValueString($forum_link, "text") ,GetSQLValueString($topic_down_times, "int"),GetSQLValueString($ext, "int"), GetSQLValueString($website, "text"));
                       mysql_select_db($database_mdc, $mdc);
                       $mzk_result = mysql_query($mzk_sql, $mdc) or die("can not do more");

                       mysql_close($mdc);

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql