Search the Community
Showing results for tags 'inserting data'.
-
I completed a whole website using Dreamweaver and Xampp, all local tested ... so happy . I now transition the Databases and everything via FTP. I have tested the connections with this code: This page is located in the localhost/Connections/security.php <?php $hostname_nglmain = "hostname here"; $database_nglmain = "DB Name"; $username_nglmain = "username here"; $password_nglmain = "my password!"; $nglmain = mysqli_connect($hostname_nglmain ,$username_nglmain,$password_nglmain,$database_nglmain); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }else{ echo "we are good"; } ?> and i get We are good when i call the test insertions page i created <?php require_once('Connections/security.php'); ?> <?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']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO testtable (id, `data`) VALUES (%s, %s)", GetSQLValueString($_POST['id'], "int"), GetSQLValueString($_POST['data'], "text")); mysql_select_db($database_nglmain, $nglmain); $Result1 = mysql_query($insertSQL, $nglmain) or die(mysql_error()); } ?> <!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><input type="text" name="id" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Data:</td> <td><input type="text" name="data" 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="MM_insert" value="form1" /> </form> <p> </p> </body> </html> I can not get the records to insert .. am i missing something during the transfer ... I am sure it had to be a coma or a period somewhere .... but I need help When i hit insert i get a we are good, page goes blank Thx in advance