mysqli

Select the newest data in an SQL table? [closed]

a 夏天 提交于 2020-01-17 16:31:25
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . I have a table for news and I want to select the 3 newest things in each row, they're numbered 1 as the oldest and each data I add it will be a number higher. So how do you get the three newest things and display the them in places? (Sorry I can't think of how to phrase my question) EDIT: I don't

PHP: Convert INSERT MySQLi to PDO [duplicate]

社会主义新天地 提交于 2020-01-17 14:46:31
问题 This question already has an answer here : Changing from mysqli to pdo (1 answer) Closed last month . I'm new in PDO programming. Based on my question, can anyone help me to convert MySQLi to PDO? Below is the code: <?php require_once "config.php"; $photo_before = $_POST['photo_before']; $report_id = $_GET["report_id"] ?? ""; $sql_query = "UPDATE report SET photo_before ='$photo_before', time_photo_before = NOW(), ot_start = '16:00:00' WHERE report_id = '$report_id'"; if(mysqli_query($conn,

MySQLi If condition alert msg not showing the output

微笑、不失礼 提交于 2020-01-17 14:09:11
问题 Below Given code working perfect. Db table also values are inserted. But Echo Message not showing in output <?php define('DB_SERVER', 'localhost'); define('DB_USERNAME', 'root'); define('DB_PASSWORD', ''); define('DB_DATABASE', 'admin'); $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE); if(isset($_POST["register"])) { $id = $_POST["id"]; $name = $_POST["user_name"]; $password = $_POST["password"]; $query = mysqli_query($db, "INSERT INTO user (id, user_name, password)VALUES

Posting multiple variable in URL and working with checkboxes

谁说胖子不能爱 提交于 2020-01-17 11:06:39
问题 This is based on the following example: http://www.w3schools.com/php/php_ajax_database.asp The differences are mainly that I am using checkboxes instead of select and where I would want to be able to select multiple items across multiple checkboxes forms: Below are the two problems I have: I want to be able to post multiple variable in the URL because as of now only one variable can be posted, and I get an error for the one not selected. I want to be able to select multiple checkboxes at once

Clarity on PHP Prepared Statement Escaping

狂风中的少年 提交于 2020-01-17 10:19:37
问题 I know this is quite a popular question and, having researched for many hours now, I am still a little unsure on a definitive answer. I am no pro at PHP and have been self teaching for a little while now. I have just recently got my head around MYSQLi prepared statements (having been used to the old practice). My main question is trying to find a definitive answer on the requirement to use real escape string (or any other security) when using prepared statements. I have ready through the

Insert one or more sets of fields into database using dynamic form

本秂侑毒 提交于 2020-01-17 08:06:30
问题 This is my second post on the same issue, in my first post I was using mysql instead of mysqli so I have made some updates according to recommendations. I have a form with variable sets of fields (1 to 20 sets) controlled by the user via javascript. Without the dynamic content all works well. After I changed my html form from city to city[] it obviously stopped passing the data to my database. I have tried all sorts of ways to make this work with no success. Any ideas? Form manipulation: var

Is it possible to nest mysqli commands [closed]

我怕爱的太早我们不能终老 提交于 2020-01-17 08:01:07
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . Using the php mysql functions, if I have a query that I know will only return one row from the data table I nest the functions like

PHP inserting data to mySQL two times instead of one

点点圈 提交于 2020-01-17 06:23:45
问题 <?php $servername = "localhost"; $username = "root"; $password = "pass"; $dbname = "test"; $name="admin"; $pass="passerino"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }else { echo nl2br("Conected \n"); } $sqlin="INSERT INTO data_test (username, password) VALUES ('valname','valpass')"; $result=$conn->query($sqlin); if ($conn->query($sqlin) === TRUE) { echo "New record

Moving of data from old table to another table PHP MYSQL

人走茶凉 提交于 2020-01-17 06:08:46
问题 i have some problem on creating a delete query on my code. the flow will be, moving data from one table to another, im placing delete codes but its not working my code <?php require_once('php/dbase.php'); $query="INSERT INTO tbl_user (username, password, access_type) VALUES ('".$_POST['user']."','".$_POST['pass']."','staff')"; if($mysqli->query($query)){ $id=$mysqli->insert_id; $query2="INSERT INTO tbl_accounts (id,fname,mname,lname,gender,designation,s_question,s_answer) VALUES (".$id.",'".$

Why is MySQLi statements bind_param giving this error? [duplicate]

我们两清 提交于 2020-01-17 04:51:10
问题 This question already has answers here : mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables (3 answers) Closed 2 years ago . Getting an error with my code found HERE... Which is a culmination of all the chatter from HERE which was "Answered" but did not fix my error. ($data is html form data) I have even gone out of my way to line up each variable, ?, DB column, and bind character in the hopes that it'll be a little more clearer. I