gbengasupowale807 Posted May 9, 2018 Share Posted May 9, 2018 This codes works on local server(XAMPP) but does not seems to work on live server. And I can't really figure out what the problem is since there no error is output in the errorlog. In the script, I tried to use the--pre--tag but also nothing gets displayed <?php session_start();?><!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Testimony</title></head><body><?phptry {$linkas = 2;require_once 'db/DBConnect.php';$errors = [];$good = true;if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['testimony'])):$testimony = /*filter_input(INPUT_POST, 'testimony', FILTER_SANITIZE_STRING)*/$_POST['testimony'];echo $testimony;if (strlen($testimony) < 20)://report error and do not go$errors[] = 'It has to be more than 20 characters' . '<br>';$good = false;else:echo $testimony;$good = true;if ($good):$insertTestimony = 'INSERT INTO testimony(content, j_member_id) ';$insertTestimony .= 'VALUES (:testimony, :user_id)';$insert = $conn1->prepare($insertTestimony);$insert->bindValue(':testimony', $testimony, PDO::PARAM_STR);$insert->bindValue(':user_id', $linkas, PDO::PARAM_INT);$insert->execute();if ($insert->rowCount() == 1)://success message//$_SESSION['msg'] = 'Thanks for the testimony';header('Location: index.php');else://fail messageecho 'Something is wrong, please resubmit';endif;endif;endif;endif;} catch (Exception $e) {echo 'Database error: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine();}?><section class=""><article><form action="" method="post" id="testimony" accept-charset="utf-8"><fieldset><legend>Your testimony</legend><label for="testimony"></label><textarea id="testimony" name="testimony" maxlength="300"><?phpif (isset($_POST['testimony'])):echo htmlspecialchars($testimony);endif;?></textarea></fieldset><input type="submit" name="testify" id="testify" value="Testify"></form></article></section></body></html> And this is the database connection string which I used to connect to the database and its located inside the db folder <?php //Db connection 1$username ="XXXXX"; // censored for SO$password = "XXXXX"; // censored for SO//$database = "xzelanet_180days";//$server="localhost";$conn1 = new PDO('mysql:host=localhost;dbname=xzeere_30days; charset=utf8', $username, $password);$conn1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); After the form submission, the form refuses to insert into the database(the form displayed but does not submit[i think the problem should be inside the code processing the form]) Link to comment Share on other sites More sharing options...
gbengasupowale807 Posted May 9, 2018 Author Share Posted May 9, 2018 XAMPP version is PHP 7.0.13 while live version is 5.6.33 Link to comment Share on other sites More sharing options...
Larry Posted May 11, 2018 Share Posted May 11, 2018 Hmmm...it's most likely b/c the live server isn't configured the same way, likely not having the same extensions, I imagine. You should turn on display_errors or look at the error logs to see the actual error occurring. Knowing the actual error is the only way to debug this. Link to comment Share on other sites More sharing options...
Recommended Posts