+ 1

website does not retrieve data from my database

This is my php <?php session_start(); if (!isset($_SESSION['user'])) if (!isset($_POST['user'])); $_SESSION['authuser'] = 0; include'Connections/config.php'; if (isset($_POST['pdata'])) { $pdata = $_POST['pdata']; } { // Check if data has be sent $connection = mysqli_connect($db_host,$username,$password, $databaseName); if (!$connection) { die("Database connection failed: " . mysqli_connect_error()); } // 2. Select a database to use $connection = mysqli_connect($db_host,$username,$password, $databaseName); if (!$connection) { die("Database selection failed: " . mysqli_error($connection)); } $tbl_name="account"; // Table name $accountID = $_SESSION['user']; $sql= "SELECT * FROM WHERE `Tracking_ID`='".mysqli_real_escape_string($connection,$_POST['user'])."'"; $result=mysqli_query($connnection, $sql) or die(mysqli_error($connection)); $count = mysqli_num_rows($result); //Mysqli_num_row is counting table row //If result matched $myusername and $mypassword, table row must be 1 row echo $count; if($count==1){ $_SESSION[trackid] = $_POST[user]; echo '<meta http-equiv="refresh" content="0 URL=trackerror.html" />'; /*$_SESSION['authuser'] = 1; header ("Location:" . $_SESSION['redirect'] . ""); */ } else { /*// When tracking Number is Correct*/ session_unset(); // Get redirecting path if (isset($_POST['redirect'])) { $_SESSION[redirect] = $_POST['redirect']; } else { $_SESSION[redirect] = "tracking.php"; } } // check if data is send to DB ?>

5th May 2018, 7:52 PM
Kelly Arnold
Kelly Arnold - avatar
10 odpowiedzi
+ 5
You have typo in your connection variable $connnection
5th May 2018, 10:03 PM
Toni Isotalo
Toni Isotalo - avatar
+ 4
You are missing your table name SELECT * FROM $tbl_name WHERE
5th May 2018, 8:15 PM
Toni Isotalo
Toni Isotalo - avatar
+ 4
Because it doesn't know where to retrieve from. --database ($databaseName) --table (missing) --row --column ('Tracking_ID') --column You have set the database name and the column name but the table name is missing. You need to check what your table is called and use it
5th May 2018, 8:38 PM
Toni Isotalo
Toni Isotalo - avatar
+ 3
You are using it as column name. "SELECT * FROM table_name_here WHERE `Tracking_ID`='".mysqli_real_escape_string($connection,$_POST['user'])."'";
5th May 2018, 8:34 PM
Toni Isotalo
Toni Isotalo - avatar
+ 1
wow! how did I miss that. thanks., just corrected it $connection. yet [05-May-2018 22:09:48 UTC] PHP Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/spider/public_html..... line 28
5th May 2018, 10:18 PM
Kelly Arnold
Kelly Arnold - avatar
+ 1
Thank you All, I have sorted it out. I was mixing MySQL and MySQLi syntax
5th May 2018, 11:25 PM
Kelly Arnold
Kelly Arnold - avatar
0
What error codes are you getting?
5th May 2018, 8:04 PM
ODLNT
ODLNT - avatar
0
here is the thing, the website doesn't retrieve data/information from the database.
5th May 2018, 8:35 PM
Kelly Arnold
Kelly Arnold - avatar
0
$sql= "SELECT * FROM account WHERE `Tracking_ID`='".mysqli_real_escape_string($connection,$_POST['user'])."'";
5th May 2018, 9:02 PM
Kelly Arnold
Kelly Arnold - avatar
0
Look at the error I got [05-May-2018 21:11:05 UTC] PHP Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/spider/public_html/courier/Admin.php on line 28
5th May 2018, 9:18 PM
Kelly Arnold
Kelly Arnold - avatar