Entering data with PHP

  • chessa
  • Newbie
  • Newbie
  • chessa
  • Posts: 5

Post 3+ Months Ago

Hi there fellaz-
I'm not sure where this problem derived so i really need a second pair of eyes for this issue.

The Problem:
you can successfully enter data via the PHP pages however when you go into mysql to view the data thats been entered you see "NULL" in the breed column.

Whats interesting:
When you go in and manually enter the data from the MyPHPAdmin interface you get all the fields successfully entered (even the breed).

At Present:
I'm not sure what to look for anymore..
But for some reason I'm thinking its the .php file thats causing the issue

Thanks alot in advance ma friend... Here's the PHP

[code]
<?php require_once('Connections/connPets.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "insert_dat")) {
$insertSQL = sprintf("INSERT INTO adoption_list (species, breed, name, age, personality) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['species'], "text"),
GetSQLValueString($HTTP_POST_VARS['breed'], "text"),
GetSQLValueString($HTTP_POST_VARS['name'], "text"),
GetSQLValueString($HTTP_POST_VARS['age'], "int"),
GetSQLValueString($HTTP_POST_VARS['personality'], "text"));

mysql_select_db($database_connPets, $connPets);
$Result1 = mysql_query($insertSQL, $connPets) or die(mysql_error());

$insertGoTo = "insert_yeah.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

print( $insertSQL );

Then, you will get the sql string used by the PHP file, copy paste it to the phpMyAdmin....

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 56 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.