For some reason I am having a really difficult time getting my PDO connection to work. I am entering the correct host, username and password that has allowed me to get into the same database, but other tables.
I have my connection setup like the following, other than the actual username, password and db entered in. I have checked it 10x and it is the correct information.
The latest error I have recieved in the error reporting file is this:
[25-Oct-2016 13:22:07 America/Chicago] PHP Parse error: syntax error, unexpected '$servernameCon' (T_VARIABLE)
I have changed localhost to the Dedicated IP Address, which I do not have to do for any other connection on my site, and even doing this still doesn't help.
I am at a loss for what I am doing wrong. Does anyone see anything I am missing?
$servernameCon = 'localhost';
$usernameCon = ' ';
$passwordCon = ' ';
$con = new PDO('mysql:host='.$servernameCon.';dbname= ', $usernameCon, $passwordCon);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Before $servernameCon:
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once 'core/init.php';
if(Input::exists()) {
if(Token::check(Input::get('token'))) {
if(Input::exists()) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'firstname' => array(
'required' => true,
'min' => 2,
'max' => 50
),
'lastname' => array (
'required' => true,
'min' => 2,
'max' => 50
),
'email' => array (
'required' => true,
'min' => 2,
'max' => 50
),
'phone' => array (
'required' => true,
'min' => 7,
'max' => 12
),
'network' => array (
'required' => true
),
'birthday' => array (
'required' => true
),
'username' => array(
'required' => true,
'min' => 4,
'max' => 20,
'unique' => 'users'
),
'password' => array(
'required' => true,
'min' => 6
),
'password_again' => array(
'required' => true,
'matches' => 'password'
)
));
if($validation->passed()) {
$user = new User();
$salt = Hash::salt(32);
try {
$user->create(array(
'firstname' => Input::get('firstname'),
'lastname' => Input::get('lastname'),
'email' => Input::get('email'),
'phone' => Input::get('phone'),
'network' => Input::get('network'),
'birthday' => Input::get('birthday'),
'username' => Input::get('username'),
'password' => Hash::make(Input::get('password'), $salt),
'salt' => $salt,
'joined' => date('Y-m-d H:i:s'),
'group' => 1
));
($user->lastId);
//Add user to posts table
if(isset($_POST['submit'])){
$id = ( isset( $_SESSION['id'] ) ? $_SESSION['id'] : "" );
$user_id = $user->lastId;
$posts = 0;
$conversations = 0;