FAQ Database Discussion Community


Why am getting this error?: Unknown column 'firstname' in 'field list'

php,database,mysqli
if(isset($_POST["submit"])) { // Details for inserting into the database $id = htmlentities($_POST["id"]); $firstname = htmlspecialchars($_POST["firstname"]); $lastname = htmlspecialchars($_POST["lastname"]); $username = htmlspecialchars($_POST["username"]); $password = htmlspecialchars($_POST["password"]); // Dealing with inserting $query = "INSERT INTO `myDatabaseForAll`.`users` (`id`, `firstname`, `lastname`, `username`, `password`) VALUES (NULL, $firstname, $lastname,$username,$password)"; $result = mysqli_query($connection,$query);...

MySQLI- Allow the Forward Slash to be Used With Insert Statement

php,mysql,mysqli,escaping
I have a MySQL field ("imagelocation") that contains the relative pathname to an image. Essentially the construct: "DirectoryName/ImageName.png" The "/" is causing a problem. I get the error message: "Unknown column 'Analog' in 'field list'" (Analog is the name of the directory.) Prior to building the pathname, the following code...

PHP mysqli_stmt::bind_param number of variables does not match

php,mysqli
While binding variable to my prepared statement PHP reports that the number of parameters do not match ! here is the code: private $q_setQueue = "update rivr_queues set name='?', description='?' where QueueID='?';"; . . . $stmt = $astdb->prepare($this->q_setQueue); $stmt->bind_param('sss',$qName,$qDesc,$qID); number of parameters is three so I think the code is...

Creating one PHP array from two sql tables

php,mysqli
I am not the best at writing complicated (for me) mysqli queries. I am trying to create one array using data from two different tables. TABLE 1: text_strings id string 1 hello 2 good_morning TABLE 2: text_translations id textid lang translation 1 1 en Hello 2 1 es Hola 3...

I need help using a class in a function in PHP

php,mysql,pdo,mysqli
I'm trying to convert all my mysqli over to PDO, but I'm pretty green with PDO and my problem might be elementary. I'm having trouble with the first query I'm switching over. Here is my setup. In my login.php, I call a function like so: login.php $user = attempt_login($username, $password);...

mysql query retrieve too slow from 10,000 of data (Query Optimizing)

php,join,mysqli,subquery,left-join
10,000 of data in memberships, members and payments table. Retreiving the query is too slow, while searching a particular payment status in each members latest payment. SELECT m.id AS member_id, m.full_name, m.unit, m.street, m.block, m.country, m.postal_code, cat . * , cat.id AS cat_id, mem.membership_num, mem.id AS membership_id FROM memberships mem...

Can not get data from database in ECHO

php,mysql,mysqli
My edit.php code is stated below, and this is what the outcome is: http://i.imgur.com/lt89Wi8.png But what it is supposed to do is, get the information from the username - loggin_session, and show their server details , so they dont have to re-write everything. see: http://i.imgur.com/fGEsXPq.png <?php $query = "SELECT id,...

Database connection successful but not able to insert data into database using php [on hold]

php,mysqli
I have been struggling for about a week now and still have not got any results. I have read the following questions: Unable to insert form data in MySQL database Connection to database seems successful but INSERT INTO sends no data PHP MySQL not inserting into database http://askubuntu.com/questions/435746/unable-to-send-data-to-mysql-database-it-is-not-taking-by-my-php-code I tried...

Getting a 'Could Not Find Driver' message with new domain name [closed]

php,mysql,pdo,mysqli
I am using a php framework and am successfully using it with the first website I created. I bought a new domain and am working on my second site. The php framework I have is basically for registering/signing in with a lot of other things, but that's the core essentials...

Grouping JSON output according to specific mysql column

php,mysql,json,mysqli
I have a mysql table (name:"messages") that has three columns as below: messageID, fromUserID, content I wish to have a json output using php script like following format; I need to seprate messages of each user (fromUserID column). JSONOutput: { "newCount":"x", "messages": [ { "fromUserID":"x", "messagesArray": [ {"messageID":"x","content":"xxx"}, {"messageID":"x","content":"xxx"}, {"messageID":"x","content":"xxx"}...

Display multiple rows in html

php,mysql,mysqli,row
I am having an issue with pulling info from the database and displaying it on the page. In the table I have multiple entries in each column. So I need to pull that info and display it in a descending order from the column id. But with this it displays...

PHP get one row from an array based on a variables value

php,arrays,mysqli
If i create an array from results returned in a mysqli query is there a way to select and use only one specific row from the array? $info= array(); while($row = mysqli_fetch_assoc($query)) { $info[] = array( 'id' => $row['id'], 'location' => $row['location'] ); } How would i go about displaying...

Fastest way to find different rows in two mysql tables

php,mysql,sql,mysqli
I have two almost identical tables. Second one is a "slave" of first one. First table has autoincrement int ID column and second also has ID2 which is indexed unique int, but not autoincremented. ID2 is an analog of ID. I need to find fastest way to detect new rows...

Why my mysql transaction is not working properly?

php,mysql,mysqli,transactions,database-connection
I've been reading and gathering information for 2 days already and I give up. I have no clue why my piece of simple code is not succeeding. I want to insert data from one form into two tables and YES I know there are exactly same problems described here and...

Skips the first repeated Value and fetch the 2nd Value - PHP

php,mysqli
PHP and MYSQLi I am trying to get the below output: for a Project ID (PJ006) I put the "date" column in Descending order first and then i want to skip all the Repeated value of the first value (Skip all entries of EM207) and display the immedate 2nd value...

mysqli added empty value on query

php,mysql,arrays,mysqli
Im doing a query that im trying to split into an array like this: $sql = "SELECT *FROM questions"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $myString = $row["qID"] . "," . $row["question"] . "," . $row["answer"] . "%"; $myArray = explode('%', $myString); print_r($myArray); }...

Is displaying data via session-value a bad practice in PHP

php,mysqli
I am wondering if this is a bad practice and if there is a better solution(since there always is!) My PHP app has a login that stores the user id/user name/etc in a session, then i create a var in my function like so; //Example user_id: AbCe3496cdA51 $sessionSelectCustomer = $_SESSION['user_id'];...

Function/Trigger already in use?

php,html,mysql,mysqli
Im having problems getting an update function to work. The function marks badges as seen so that they are hidden from a notification window. The function is called when the user clicks a button to mark them as seen. I have two triggers on the table its trying to update...

Retry on database exception using php

php,exception,mysqli
I have been working on exceptions thrown by php - mysqli & created this snippet below that tries to check a few times to see if a temp glitch has caused the database to fail. if so, it tries to recover. If it cannot then it quits/ ends. Now while...

Email is already in database, returns as if it isn't

php,mysqli,registration
Here is some background information on what I'm trying to do here. I'm try to create a registration form for my website (successful so far until this point). Data can be entered into the DB. The only thing I'm trying to do now is prevent duplicate email/usernames from being entered...

Why is my script failing me? get ip [closed]

php,mysql,mysqli
Why is my script not managing to get the correct information and inserting it into the database. I want to get the client IP , and the time/ date. My $ip function <?php // Function to get the client IP address function get_ip_address() { // check for shared internet/ISP IP...

Prepared statement not running MYSQLI PHP

php,mysqli,prepared-statement
I have been attempting to switch over to prepared statements, however I cant figure out why my new code no longer functions. I am new to using these and still learning but i understand it is the best practice for security. any help would be appreciated. Thank You. <?php $servername...

PHP displaying data from four tables in one query (ie: LEFT JOIN)

php,mysql,sql,mysqli,left-join
I have three tables: I want to display 'Event Details' which shows attending employee details (listo f employee ids from the 'attending_employees table > corresponding employee details form 'employee' table), what team they belong to (from the club_teams table) and the event details from the 'club_events' table). Currently I am...

need to fetch all the students who have not paid for the current month

php,mysql,mysqli
I have two tables Students table : id studentname admissionno 3 test3 3 2 test2 2 1 test 1 2nd table is fee : id studentid created 1 3 2015-06-06 22:55:34 2 2 2015-05-07 13:32:48 3 1 2015-06-07 17:47:46 I need to fetch the students who haven't paid for the...

How can I delete the echo of an HTML table?

php,mysqli
I have the following code for the echo of an HTML table. In the table is a delete button. I want to delete the user's input from the database when the user hits the delete button. In the database there are more rows from the same user with different values...

Another beginner with a mysqli issue

php,mysql,sql,database,mysqli
I'm quite new to working with PHP and databases. So, like all beginners, I'm having problems with the mysqli extension. I was trying to avoid using mysqli_results, as I didn't want to deal with an array and a loop every time I want a simple piece of data. But that...

Mysql syntax error on LEFT JOIN query [closed]

php,mysql,sql,mysqli,left-join
I am trying to execute a LEFT JOIN query however I am getting a syntax error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN lr_users ON lr_capped_members.user = lr_users.user_id WHER' at...

MySQLi present still not connecting to database

php,mysql,mysqli
I ran var_dump(function_exists('mysqli_connect')); and it returned boolean true. I am running the following code <?php $connect=mysqli_connect("localhost","root","root","dbname") or die("Unable to Connect"); $showtablequery="SHOW TABLES FROM dbname"; $query_result=mysqli_query($showtablequery); while($showtablerow = mysqli_fetch_array($query_result)) { echo $showtablerow[0]." "; } ?> It did not do anything. It did not print anything on the result webpage. When I...

Fatal error in if stament [duplicate]

php,mysql,mysqli
This question already has an answer here: Compile Error: Cannot use isset() on the result of an expression 2 answers Error - Cannot use isset() on the result of an expression (you can use "null !== expression" instead) I'm getting the error above the start of the if statement...

Creating a php class for database insert functions

php,mysqli
I am trying to create a class to save time on cleaning up my variables before sending them to the database to prevent sql injections. The basic systems is working now but i cant seem to get a where/or statement implemented. Does anyone know how to add this? <?php class...

mysql LEF JOIN with LIMIT

php,mysql,mysqli
I have 2 tables: games: g_id | country | team_1 | team_2 -------------------------------- 1 | England | Bayern | Chelsea 2 | England | Bayern | Liverp 3 | England | Bayern | Ajax statistic: s_id | s_time | s_name | g_id ----------------------------- 1 | 4 | Alen A. |...

Call to a member function error in mysqli query

php,mysqli
The below method is returning an error after I added && in_array($itemID, $userItemIDS) to the if statement. Fatal error: Call to a member function bind_param() on a non-object /** * Deactivate item. * * @param (int) $itemID - Variable representing an item's id. */ public function deactivate($itemID) { //get user...

PHP mysqli_fetch_array() OOP style

php,oop,mysqli
I want to run a SELECT query and fetch data as associative array and echo the fetched data. In procedural style I would use mysqli_fetch_array(). But I am now trying OOP style. I have tried this code: $con= new mysqli('localhost','root','','afiliate'); $query="SELECT * FROM product WHERE ID=? "; $stmt->bind_param("i",$ID); /* $ID...

Mysqli connection in function PHP

php,mysqli
I'm facing a PHP problem. I've searched the web but couldn't find the answer. This is my code so far: <?php $db_host = 'db_host'; $db_user = 'db_user'; $db_password = 'db_password'; $db_name = 'db_name'; //not showing you the real db login ofcourse $conn = mysqli_connect($db_host, $db_user, $db_password, $db_name); if($conn) { echo...

Putting MySQL data into an array

php,mysql,arrays,mysqli,store
I've tried for a couple of days to get all of the data from a MySQL column and put it inside an array, formatted in the following way: $aSpam= array ( '.info'=> 'i' , 'anal'=> 'i' , 'anus'=> 'i' , 'arse'=> 'i' ) I've managed to echo it out formatted...

PHP json_encode return empty array on the first index from MySQL table

php,mysql,arrays,json,mysqli
Hi I'm new to PHP and I'm trying to get data from MySQL table as array of JSON. I did get the array of JSON from PHP file, but there is an empty array on the first index. Here is my table structure from creating on MySQL it : CREATE...

mysql select values which coincide with all the elements of the list

mysql,mysqli
How to make mysql requst to select all values, that contains all elements of list. I have table like this: +--------+------------+ | carID | serviceID | +--------+------------+ | 1 | 12 | +--------+------------+ | 1 | 13 | +--------+------------+ | 1 | 15 | +--------+------------+ | 2 | 12 |...

MySQLi queries runs on each browser refresh

php,mysqli
When I run this code, the "INSERT INTO aks_balance_history" query and "UPDATE aks_account" query runs again and again.Also database is getting updated on each refresh, while the "UPDATE aks_counter" runs only once (as required). I am really stuck in this code please help. if(isset($_POST['update_btn_counter'])) { mysqli_query($link,"INSERT INTO aks_balance_history(bh_amount,bh_from,bh_to,bh_reason) VALUES('".$_POST["used_balance"]."','Counter Cash','".$_POST["select_account"]."','".$_POST["reason"]."')...

invalid object or resource mysqli_stmt

php,mysql,mysqli,prepared-statement
I want to run multiple mysql queries( not concurrently). I am using prepared statements for doing so. This is a gist of my code : <?php if(isset($_GET['username'])&&isset($_GET['activationid'])){ require_once("../database/db_connect.php"); $stmt= $mysqli->stmt_init(); $stmt->prepare("Select username FROM users where username= ? AND activationid= ?"); $username=$_GET['username']; $activationid=$_GET['activationid']; $stmt->bind_param("ss",$username,$activationid); $stmt->execute();...

MYSQL innoDB SELECT FOR UPDATE with LEFT JOIN

sql,mysqli,innodb
Can somebody please tell me what happens when you LEFT JOIN tables for a SELECT FOR UPDATE using an innoDB storage engine. Do all the rows from all the joined tables get locked, or is only the primary table rows? For example, if I do.. SELECT userID, countryID FROM user...

MySQLi “CURRENT_MONTH_BEGINNING”… is there a way to get that?

php,date,mysqli
I am interested in collecting data from the last month in the database with MySQLi. But using INTERVAL 1 MONTH each month overlaps the other, so is there a way to tell the function to check my current month, start from the first day, and collect all data from said...

SELECT * FROM WHERE Query isn't retrieving any results

mysql,select,mysqli,fetch
I'm using a SELECT * FROM "" WHERE "" = "" query and I'm not sure what I'm doing wrong with it. I'm trying to select an item based on its PO which is a completely unique identifier to one row in the table. Here's my process in doing so:...

mysql_result() expects parameter 1 to be resource, object given

php,mysql,mysqli
As a part of a login system I need to check if the username exists in the database so I created a query that checks if the username the user entered already exists. With mysql_result I check if the id is larger as null. If yes: user exists and if...

How to check if data already exists then randomly generate new data from an Array

php,mysql,arrays,mysqli
Okay so, I made an array containing 270+ different strings. The main goal is too echo out 60 strings from that array and combine them.. Ex. 1.String, 1.String2. The 2 echo'd out strings are a combination, and should be together like 1-1 and 2-2, 3-3, and ect. In total there...

mysqli_result value to variable in php

php,html,mysql,mysqli
Echo of facultyname is showing a value but fid is not getting value. I want to assign value of fid to a variable. $facultyname=$_POST['facultyname']; echo $facultyname; $query="SELECT fid FROM faculty WHERE fname='$facultyname'"; $fid_result=mysqli_query ($link,$query); $finfo = mysqli_fetch_field($fid_result); printf("FacultyID :- %d ",$finfo->fid); ...

How to change values in a json array

php,arrays,json,mysqli
I have this JSON array from a mysqli query, and I need to change some of the values inside it, before passing it to Datatables. "released" : 0 should print "No", and "Yes" if value is 1. "sex" : 1 is female, and "sex": 0 is male. How can I...

How to get a single value from a query result in php

php,mysqli
I am trying to get single value from DB with single query. i mean that i already featched all values in one query from that i need to get only one column value. $connection = mysqli_connect($servername, $username, $password, $dbname); $query = mysqli_query( $connection,"select * from register where password='$log_in_password' AND username='$log_in_username'");...

jquery mobile login form with php

php,mysqli
I have struggled with the code forever!! I keep getting the invalid password error and however many times I adjust where the hashing is or where to check the password I still get it even though i place the correct password for different users...I really need some help! The table...

Fatal error: Uncaught exception 'mysqli_sql_exception' with message

php,mysqli
I want to get a value from the user and then update the start time and end time for biding in the table. But i am getting this error: Fatal error: Uncaught exception 'mysqli_sql_exception' with message Table 'fyp.biding' doesn't exist' in C:\xampp\htdocs\fyp\profile\user\sadd_property_bidding.php:61 Stack trace: #0 C:\xampp\htdocs\fyp\profile\user\sadd_property_bidding.php(61): mysqli_query(Object(mysqli), 'UPDATE biding S...')...

How to get Fields Flags Name with SQL Query

php,mysql,mysqli
Actually I want to Display Flags Name of all fields which is belongs to a table. This is Our script, from which i am performing this action. <?php mysql_connect("localhost", "root", ""); mysql_select_db("DatabaseName"); $result = mysql_query("SELECT * FROM Table_Name"); $fields = mysql_num_fields($result); for ($i=0; $i < $fields; $i++) { $flags =...

HTML & PHP | Filling a select with a query

php,html,mysqli
I have a function that uses mysqli function that is as follows: public function GetProjectOptions() { $return = ""; $sql = "SELECT `id`, `project_name` FROM `projects`;"; $rs = static::$link->query($sql); $return .= '<select class="form-control" name="project">'; while ($result = mysqli_fetch_assoc($rs)); { $return .= "<option value='" . $result['id'] . "'>" . $result['project_name'] ....

MySQLi LEFT JOIN query is throwing a syntax error

php,mysql,join,mysqli,left-join
I have two tables 'lr_users' and 'lr_ranks' with the following table structures: lr_users: user_id(pk), username, rank(fk), job_id(fk), date_joined lr_ranks: rank_id(pk), name $qry= mysqli_query($con, "SELECT lr_users.username, lr_users.rank, lr_users.job_id, lr_users.date_joined lr_ranks.name AS rankname FROM lr_users LEFT JOIN lr_ranks ON lr_users.rank = lr_ranks.rank_id")or die(mysqli_error($con)); $rows = mysqli_num_rows($qry); Above is my PHP code for...

how to get list of product having a specific property id's in mysql

mysql,mysqli
i have a table having columns 'product_id' and 'property_id'. Some products having both property 20 & 21, some of them only have 20 or 21. product_id property_id 1 20 1 21 2 20 3 21 3 20 4 21 I need to get list of product having both property_id 20...

jquery form inserting with php

php,jquery-mobile,mysqli,insert
please help find the sourse of my codes issue...when I click request the page just refreshes with all the data gone but nothing is inserted into the db... here is the image of the db and the code! what do I need to change to be able to insert the...

PHP login not working (comparing plain submitted password with encrypted one) [duplicate]

php,mysqli,login,passwords
This question already has an answer here: Secure hash and salt for PHP passwords 13 answers I'm trying to make a login with prepared statement but kept failing so I let every step have an echo when failed. I get a "Password verify: (0)" so i'm guessing the problem...

PHP - mysqli :Count if database returned any record

php,mysqli
i am trying to query database on the basis of given username. If username matches i want to return true , following is my code <?php function user_exists($username){ $username= sanetize($username); $query= mysqli_query($connect, "SELECT COUNT('user_id') FROM users WHERE username= '$username'"); if(mysqli_num_rows($query)>0){ return TRUE; } } problem is that when i try...

Get random rows if full text result is less than N rows

mysql,sql,mysqli,full-text-search
I am using below code to find something SELECT * FROM table WHERE MATCH(title) AGAINST('php tutorial') LIMIT 25 If there are titles that match my query, It returns 25 rows. If the row is empty or if less than 25 rows I want to get random 25 rows from table....

MYSQL order NULL between two particular records and data

mysql,sql,mysqli,phpmyadmin
Is there a way to set the default order used by MYSQL to be NULL in a specific record. my columns: id : id state : 'downloading','error','finish','fail' try : number of try for download file. order in result: downloading error : if try between 0 to 20 NULL error :...

Not giving right error message in security PHP script [closed]

php,mysqli
Im working on a simple forum script and i made some security feature against posting empty value`s. Problem is its not giving me the right errors its just showing the first error message "U havent filled in a title.". Can anyone see the error because i cant. Code: <?php include('include/configdb.php');...

how to return boolean using mysql EXISTS

php,mysql,mysqli
I want to get a boolean output to a mysql query. i issue a query like the following EXISTS ( select 1 from someothertable where someaccid = ( select someid from smtable where username = 'someuser' and password = 'somepassword') ) This returns an error 1064 in the mysql shell...

PHP mysqli query issue when running multiple queries inside while loops

php,mysqli
I have the following php code: if($getPrepareResults = $con->prepare("SELECT machinePurposeID FROM machinepurpose WHERE machinePurposeName LIKE '%$needle%' AND machinePurposePerms=1")) { $getPrepareResults->execute(); $getPrepareResults->store_result(); if($getPrepareResults->num_rows > 0) { $found = true; $getPrepareResults->bind_result($machinePurposeID); while($getPrepareResults->fetch()) { if($getMachineID = $con->prepare("SELECT machineID FROM machinedetails WHERE machinePurpose=?")) {...

Mysqli update query doesn't work

php,mysql,mysqli
So I'm trying to build a kind of update email function, and the part that should put it into the db looks like this <?php $emailfrom = $_POST['emailfrom']; $emailto = $_POST['emailto']; $query = sprintf('UPDATE `users` SET `email`="%s" WHERE `email`="%s"`', mysqli_real_escape_string($db, $emailfrom), mysqli_real_escape_string($db, $emailto)); mysqli_query($db, $query); The problem is that the...

how to use javascript variable in php inside a javscript function

javascript,php,jquery,mysqli
i am trying to fetch JavaScript variable "i" in my PHP Code within a JavaScript function in the below code, I find problem in retrieving records, either first record or the last record repeats instead of all records in database.. can you guys help me out ? Thanks <?php $query21...

MySql count all before max(date) of row that meets certain criteria

mysql,mysqli
I'm trying to get the last recorded loss, then count the number of wins after that to calculate a win streak. BEGIN SET @maxDate:=(SELECT MAX(date) from game_scores where user_score<opponent_score and user_id=1); SELECT @maxDate as last_loss, COUNT(*) as streak from game_scores WHERE user_score>opponent_score and date>@maxDate and user_id=1; END But I keep...

How to make a table row if no data found?

php,html,mysql,mysqli
<?php include "db.php"; if ($_SERVER["REQUEST_METHOD"] == "POST") { $search_date = $_POST['search']; } $show_result = mysqli_query($con, "SELECT * FROM data_input where input_date = '$search_date' "); // var_dump($show_result); $row_count = mysqli_num_rows($show_result); echo $row_count; if ($show_result){ ?> <table class="table table-bordered table-striped"> <tr> <th>id</th> <th>date</th> <th>items</th> <th>description</th> <th>cost</th>...

Display Count(*) in PHP

php,mysql,mysqli,count
I want to display the number of rows with the word in a string of a column having "LIV" in it . This is my code. When i run query in phpmyadmin the result shows I have 2358 rows but when run in php it says only 1 row ....

Loading external php file in a div with jquery ajax

javascript,php,jquery,ajax,mysqli
i am making a simple project..and i need to load data from other page in an index.php..and i have set time of 20sec. but its not working.. could u please tell me what is wrong with the query..Thanks already.. index.php <?php include 'connection.php'; ?> <html> <head> <title> My First Chat...

GET date and insert into field - hidden field in form

php,mysql,sql,mysqli
Im trying to get a " date " field on my form, but the field must be hidden, and will insert into the database upon successful registration. The Date field will get the current Date. <form action="" method="post" name="join_form" class="form-horizontal" role="form" enctype="multipart/form-data" onSubmit="return checkform(this);"> <div class="form-group "> <label for="join_email" class="col-md-1...

Notice: Undefined variable: conn in C:\xampp\htdocs\ADZ\SystemNew\pages\usermanagement.php on line 12 [closed]

php,mysql,apache,mysqli
I'm getting two errors. Pleaseee help me figure out what to do cause I'm kinda new to php too. Notice: Undefined variable: conn in C:\xampp\htdocs\ADZ\SystemNew\pages\usermanagement.php on line 12 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\ADZ\SystemNew\pages\usermanagement.php on line 12 Warning: mysqli_fetch_array() expects parameter 1 to be...

SSL operation failed with code 1: dh key too small

php,codeigniter,ssl,mysqli,openssl
I am connecting to my database Google Cloud SQL via SSL. I use codeigniter 3.0 to do so, although the mysqli driver is a bit modified to allow this functionality. It's been working well for months. However it just started to return this warning: Message: mysqli::real_connect(): SSL operation failed with...

Most efficient way to Select all, and to include a distinct column value - while ordering by date added

mysql,pdo,mysqli
Here's the problem. I have rows that get updated automatically. Sometimes rows are updated (via a new insert - an almost duplicate row) where some columns remain the same - and other columns have new values. I want to pull the most recent up to date row; all the values....

How to use 'or' inside mysqli prepare statement query

php,mysql,mysqli,prepared-statement
I'm new to mysqli prepare statement and was surprised to find out the || doesn't work as expected in mysqli prepare statement query. I have a function which check whether the user registered, and its evaluation should be based upon the unique row id and email address.Besides, since the id...

Put a table in a php with the first row

php,html,mysql,mysqli
I am trying to put in a php page with a table and I can't see the first row and I don't know why... My code is: $search= "SELECT code_resource FROM queue ORDER BY turn ASC"; $result= $db->query($search); $queue = mysqli_fetch_assoc($result); $code = $queue['code_resource']; if($result->num_rows != 0) { echo "<table...

PHP / MySQLi: How to prevent SQL injection on INSERT (code partially working)

php,mysql,mysqli,sql-injection,sql-insert
I am new to PHP and hope someone can help me with this. I would like to store two values (an email and a password) in a MySQL db using PHP. The input is passed to the PHP page via Ajax in jQuery (through an onclick event on a website)....

mysqli_query() expects parameter 1 to be mysqli, i cant use a variable?

php,oop,mysqli
index.php <?php if(!defined('ROOT')) { define('ROOT','C:/Apache/htdocs/website/inc'); } require_once ROOT. '/config/db.php'; require_once ROOT. '/library/classes/class.User.php'; $checkUser = new userFunction(); if($_SERVER["REQUEST_METHOD"] == "POST") { $username = $_POST["username"]; $password = $_POST["password"]; $user = $checkUser->userLogin($username, $password); if($user) { echo "Succes"; } else { echo "Failed"; } } db.php <?php class dbConnect { function __construct() { require_once('config.php');...

strip_tags() on MySQLi Query and PHP Function [closed]

php,mysql,string,function,mysqli
I'm trying hard to learn how to create functions, and I don't know what I'm doing wrong here. Could someone explain it to me please? I'm not using strip_tags(), why it's getting me this error? I don't need it to return, I just to need to update database if $xp...

MySQLi query to join over several tables with pure relationship tables

php,mysql,database,database-design,mysqli
so I have this schema as shown in the image. Now while I've been trying to figure out all day how to do this, I gotta say I haven't become a bit wiser.. What I want to know is if it is possible to get a result like this from...

jquery chat with time

php,jquery,mysqli,chat
I have one simple chat worked with jquery, PHP and MySQLi... All working perfect, but I need too add time of sender message like or ps. If I am on wrong place please tell me how and where I can write. Here is all code what I have in files,...

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server

php,mysql,mysqli
Getting error with code WHERE client_id LIKE '23' Notice: Undefined variable: check1_res in /srv/users/serverpilot/apps/.../public/client/billing/service.php on line 68 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE client_id LIKE '23'' at line 1...

mysqli fetch array grabbing all data from chosen id except for the image

php,arrays,mysqli
I am storing product data in my database including the image file. I then display all of my products in one page through a foreach loop. If I click on a product it takes me to a page called viewProducts.php . In that page, I pull the information from that...

mysql multiple insert query results top 13 values are fine rest (all same don't know from where)

mysql,mysqli
The problem is when I use this query top 13 values are perfect then all of a sudden from the 14th row onwards the middle value (code) are all same for rest all of them and it is not even from the data I am providing. Tried everything changed table...

limiting amount of database queries

php,mysql,mysqli
Before reading my question please keep in mind the following is work im doing on a personal project to learn / broaden my php / mysql skills, thus im still very much a rookie as I am sure is evident in my coding which follows. However any tips / helps...

Creating a new ID using mysqli_insert_id and storing in session

php,mysqli
This was working fine before and now it's not. I'll try explain the problem best I can. I am creating a website where people post ads for horses they are trying to sell, or put on loan - people can also post if they are looking for a specific horse....

$mysqli->insert_id wont work

php,mysqli
After inserting a new row into my external database, i want to receive back the new (auto-incremented) ID that was created along with the new row. <?php $response = array(); // check for required fields if (isset($_POST['thread']) && isset($_POST['event_name']) && isset($_POST['fb_id']) && isset($_POST['status'])) { $event_name = $_POST['event_name']; $thread = $_POST['thread'];...

Can I use a subquery's result as well?

php,sql,mysqli
I have 2 tables: Ads: Fields ID, A, B and C: +----+---+-------+------+ | ID | A | B | C | +----+---+-------+------+ | 1 | x | y | z | | 2 | c | v | b | | 3 | n | n | m | +----+---+-------+------+...

page will not die() if the person is banned php mysql

php,mysql,mysqli
<?php include('session.php'); ?> <?php require_once('mysql_connect.php'); $query2 ="SELECT id, username, banned FROM login WHERE username ='$login_session'"; $result2 = mysql_query($query2) OR die($mysql_error()); $row = mysql_num_rows($result2); if($row['banned'] == 1) { die(); } ?> Session.php <?php // Establishing Connection with Server by passing server_name, user_id and password as a parameter $connection = mysql_connect("localhost", "",...

Sql syntax error using UPDATE database query [closed]

php,mysql,mysqli
evening all, i have an issue with a syntax sql error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where username = danny (name, url, banner, description, sponsor, date, password)' at line 1...

How to properly use mysqli to query and prevent injection

php,mysql,mysqli
So I am attempting to learn mysqli and do some database querying. I am using the class file that's found here Simple-Mysqli I want to make sure that I do this right to prevent any mysql injection attempts but I am having a bit of trouble. I am a mysql...

Json not returning after ajax call

php,mysql,ajax,json,mysqli
HTML PAGE $("#submit_login").click(function() { var username = $('input[name=user_email]').val(); var password = $('input[name=user_password]').val(); $.ajax({ type: "POST", dataType: "json", url: "newExam.php", data: { name: username, pwd: password }, cache: false, beforeSend: function() { $("#submit_login").val('Connecting...'); }, success: function(dataa) { if (dataa) { alert(dataa); $("#submit_login").val('success') } else { $("#submit_login").val('Login') alert('nodata') } } }); });...

jQuery keyup function stops working when trying to insert into a database

php,jquery,mysql,database,mysqli
This is a weird problem and I'm not sure how to approach it. At the moment I'm trying to have the user enter an ingredient - a list of ingredients appears as you type with buttons next to them to add them which should insert them into SQL database. The...

SQL Group By multiple categories

php,mysql,sql,mysqli
This is the query I'm using to count how many events are booked for each category of bookings. SELECT Categories.name, count(case when locations.name ='loc 1' then 1 end) as Location1, count(case when locations.name ='loc 2' then 1 end) as Location2, count(case when locations.name ='loc 3' then 1 end) as Location3,...

Return mysql result and use in another function

php,mysqli
I have a php function that gets a users ID based on their studentid. function getID() { require "connect.php"; $id = mysqli_query($connection, "SELECT id, studentid FROM users WHERE studentid = '".$_SESSION["studentid"]."'") or die(mysqli_error($connection)); $userID = mysqli_fetch_assoc($id); echo $userID['id']; // Just to make sure it works } I would like to...

Turning mysql query into prepared statement

php,mysqli,prepared-statement
I'm trying to turn the below query into a prepared statement, but I'm having no luck so far. I've attached one of my attempts. The idea is I'm using this to check how many rows are returned using mysqli_num_rows afterward. $sql2=mysqli_query($bd, "SELECT address FROM member WHERE address='".$address."'"); This is my...

Difficulty running my code in web host

php,mysqli,localhost
Currently I am having problem running my code in live server even though i can run it in my localhost. if($con->connect_error){ $response['success'] =0; $response['message'] ='could not connect to database'; print(json_encode($response)); die(print(json_encode($response))); } $response['success'] =1; $response['message'] ='successfully connected to the database'; print(json_encode($response)); $depart = $_GET['depart']; $destination = $_GET['destination']; $sql = "INSERT...

Delete Multiple Records in php

php,html,forms,mysqli
Can anyone tell me whats the problem with the code below? When I click the delete button, it gives me an error of undefined index checkbox even though checkbox is the name of the input tag below. I know I haven't written the delete query, but thats not the point....

regular expression for mysqli always returns 1

regex,mysqli
I am trying to fetch rows from my database by checking if the json in one of their fields contains a specific id. Example: col(kats): [2,4,7,9] I am trying to do so by using the following query SELECT column FROM table WHERE column REGEXP '(\[|\,)1(\]|\,)' The Problem: MySQL returns 1...

Display sponsor using if else , does not show PHP

php,mysql,mysqli
I'm trying to get a website to be highlighted on my toplist, using if else statement. When I inspect the element of a server, that is supposed to be a sponsor website, it doesn't show up as "sponsor site" css, it's still coming through as glossed ( sponsor = 0...

How to upload file in PHP and store information in SQLi database?

php,file,mysqli,upload
So I'm trying to do this file upload, and store information such as the size of the file, name, and URL of it in a database, while having the file just upload to a folder on my computer (for testing purposes). It's uploading no problem, the only issue I'm having...

calculate on alias name

mysql,sql,mysqli
i have this query SELECT number_title, (SELECT COUNT(*) FROM poll_stemmen ) AS total_number, (SELECT COUNT(ps.number_id) FROM poll_stemmen group by ps.number_id ) AS voted FROM poll_numbers AS pn RIGHT JOIN poll_stemmen AS ps ON ps.number_id = pn.id GROUP BY ps.number_id But i want to do an calculate between the voted and...

Count the number of times each members name appears in a table with a condition

php,mysql,sql,mysqli,phpmyadmin
Consider the following table: Im looking for a query that will: - Count the number of times each members name appears in the table where tournament= "EPL" AND round ="12" For this EXAMPLE the query should return: Andrew = 3 Wins Joseph = 2 wins John = 1 win Martin...