Skip to main content
Participating Frequently
May 15, 2017
Answered

Data from browser isn't available in Database (Mysql)

  • May 15, 2017
  • 2 replies
  • 985 views

Hey people,

I am in a deep trouble, I have connected mySql to my dreamweaver site succesfully but when testing in the browser the data i enter isnt visible in the database table.....and also i am getting this dynamically- relatesd content problem could this be the problem.

This topic has been closed for replies.
Correct answer Nancy OShea

<?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"] == "REGISTRATION")) {

  $insertSQL = sprintf("INSERT INTO `S and T R` (`School Name`, `School Contact No.`, `School Email ID`, `Fax Number`, `Teacher Name`, `Teacher Contact number`, `Teacher Email ID`, `T-size Teacher`, `Teacher Gender`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",

                       GetSQLValueString($_POST['School_Name'], "text"),

                       GetSQLValueString($_POST['Contact Number (school)'], "text"),

                       GetSQLValueString($_POST['School Email ID'], "text"),

                       GetSQLValueString($_POST['Fax Number'], "text"),

                       GetSQLValueString($_POST['Teacher name'], "text"),

                       GetSQLValueString($_POST['Contact Number'], "text"),

                       GetSQLValueString($_POST['Teacher email ID'], "text"),

                       GetSQLValueString($_POST['T-size Teacher'], "text"),

                       GetSQLValueString($_POST['Gender'], "text"));

  mysql_select_db($database_SBA, $SBA);

  $Result1 = mysql_query($insertSQL, $SBA) or die(mysql_error());

}

mysql_select_db($database_SBA, $SBA);

$query_Recordset1 = "SELECT * FROM `S and T R`";

$Recordset1 = mysql_query($query_Recordset1, $SBA) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

?>

the PHP code...i am not using PDO instead for my DB management i am using Mysql Workbench if that's what you were asking...

thanks to being considerate I really need this to be done, i am new to PHP and did some basic tutorials


To interact with a database you need to build a CRUD application.  Basically, a set of PHP pages that is able to  connect and Create/Read/Update/Delete data in the database. 

Have you completed that yet?

PHP CRUD Tutorial (part 1)

Nancy

2 replies

Participating Frequently
May 22, 2017

sure...no problem...thanks for your help though. If I figure this thing out it just one day job. anyways thanks for your support.

Rob Hecker2
Legend
May 15, 2017

What version of Dreamweaver are you using?

Exactly what errors are you getting?

Do you have a Web server installed and if so, which one?

What do you mean when you say: I have connected mySql to my dreamweaver site succesfully

Participating Frequently
May 17, 2017

I am using dreamweaver CC 2017 and i have made the possible connections requires (test server). i am making a registration form and therfore i have linked my DB table to the respective fields...as i try to test it out in the browser it says succesfull but as i check my DB table there is no data...

Rob Hecker2
Legend
May 17, 2017

Are you using MySQLi or PDO?

You don't mention a database plugin (such as from dmxzone or webassist) so I assume you are not using one

The following two lines of code will make PHP errors visible, in case they are not

error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', 1);

The following line of code can be used to make database errors "verbose" if you are using PDO. The variable $dbh is the variable you give the connection class

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

You should paste the relevant code into the forum so we can see if your code gives us a clue as to what is happening.