Works on localhost but not on server

<?php
error_reporting(E_ERROR|E_WARNING);

include("../includes/config2.php");

if(isset($_REQUEST['subclick'])){ $subclick = $_POST['subclick'];

// Activate reporting for OOP mysqli_*
$report = new mysqli_driver();
$report->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT;

// OOP mysqli_* is as is.
// {host, username, password, database}
$mysqli = new mysqli(HOST, USERNAME, PASSWORD, DATABASE);

// Check to see if the database connection failed
if($mysqli->connect_errno) {

    // DO NOT DISPLAY ANY ACTUAL ERROR IN HERE!!!!!!!!!!!
    // YOU LEAVE YOURSELF OPEN TO ATTACKS IF YOU DO!!!!
    die('Something is wrong. Please check your database credentials again. If this problem persists after correcting your credentials, the database engine must be down.');

} 


$type = $_POST['type'];
$event_name = $_POST['event_name'];
$event_location = $_POST['event_location'];
$event_date = $_POST['event_date'];
$event_time = $_POST['event_time'];
$event_highlights = $_POST['event_highlights'];
$event_details = $_POST['event_details'];

	$sql = "INSERT INTO events (type, event_name, event_location, event_date, event_time, event_highlights, event_details) VALUES ('$type', '$event_name', '$event_location', '$event_date', '$event_time', '$event_highlights', '$event_details')";

$prepare = $mysqli->prepare($sql); // Prepare your query string
	//$prepare->bind_param('i', $id); 
	//Bind the placeholder with its appropriate variable
    $prepare->execute(); // Execute the prepared statement
    $prepare->store_result(); // Store the result for later checking

	echo "<strong>Your Event has been posted.</strong><br>";
	echo "<a href='add_meeting_event.php'>Add another Meeting / Event</a><br>";

exit();
	

}






?>

<form action="add_meeting_event.php" method="post">

<input type="hidden" name="subclick" value="1">

<table

Please help others by formatting the script.

Start and finish the script by using three backticks on a line. Backtick key is usually top left hand of your keyboard.

Alternatively, which I have yet to try is to use the </> in the post edit box.

So you expect us to guess what “not working” means?

Slightly off-topic, but what’s the point of using the prepare() method if you’re just going to concatenate the variables into the query string?

on localhost everything uploads fine, on the servernothimg and no error message.

I have a feeling that for localhost vs. live it would be worthwhile to check
include("../includes/config2.php");

Don’t post any of the sensitive values please. The idea is to look for any setting you are unable to change. eg. something “dangerous” / costly, no longer supported.

If you have extensions / packages etc. available to localhost, are you certain dependencies are OK live ?

I was leaning to that as well but the same include works on several other files!

Define: nothing. Are you getting a blank page, a http 500 error page, is the ‘form’ page just refreshing?

Are display_errors set to ON so that any reported php errors will be displayed?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.