1

Iam trying to INSERT data from submit page if the email ID doesnt exist already. The following code works perfectly fine with local Apache. However, in GAE cloud, INSERT statement doesnt get executed at all.

    <?php
include("topmenu.php");
$student_name = trim($_POST['student_name']);
$email = trim($_POST['login_id']);
$password = $_POST['password'];

$course_name = 'Foundation Course in Website Development';

$hashed_password = password_hash($password, PASSWORD_DEFAULT);


include("cloudconnection.php");


$sql_check="SELECT * FROM User_info WHERE Email_ID='".$email."'";
$stmt1 = $db->prepare($sql_check);
$stmt1->execute();

$count = $stmt1->rowcount();
echo $count;





$sql="INSERT INTO `User_info` (Student_Name,Email_ID,Course_Name) VALUES ('".$student_name."','".$email."','".$course_name."') ";
   echo $sql;
    include("pdo.php");


   header("Location: login.php?q=1");



?>
Mithran
  • 11
  • 1
  • Always debug your scripts with enabled [PHP Error Reporting](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display)! And then post here the error you are receiving. – ino Dec 01 '18 at 07:56
  • Thanks for the response.. But tried the error reporting.. No error shown.... Further, INSERT statement works well with other table names in the same code ... but for "User_info" it is not working.... – Mithran Dec 01 '18 at 08:36
  • To note: User_info is very much valid since other statements like SELECT, UPDATE work well with it... – Mithran Dec 01 '18 at 08:42
  • it's better put your code on try catch, then instead select(to see is unique email_id or no) and insert, make email_id as unique index in your table then try first to insert, if it was existed then in catch part you will receive error code number 23000 – Fatemeh Gharri Dec 01 '18 at 08:57
  • Apparently the issue turned out to be not defining the table columns "NULL". I tried inserting data in to 5 columns whereas 12 columns were defined without any default value. In Local server, the code got executed though with warning in phpmyadmin. Solve the issue finally.... Thanks for your efforts in helping me... – Mithran Dec 02 '18 at 11:57

0 Answers0