mysqli

MYSQL order by like/dislikes and popularity

筅森魡賤 提交于 2020-01-12 06:00:31
问题 I have table of comments which includes likes and dislikes, now i have problem with proper order.. Actually my system shows comments with greatest amount of likes on top. I'm looking for something like system in youtube. It means that comment with 100like/100dislikes is higher in order than 1/1.. I hope this is understandable :) 回答1: This is classic problem how to rank upvote/downvote, plus/minus, like/dislike and so on. There are a few possible solutions but they may give wrong result in

Number of elements in type definition string doesn't match number of bind variables in /home/a3598479/public_html/Register.php on line 8

ε祈祈猫儿з 提交于 2020-01-11 14:55:52
问题 Please help me. I don't actually use PHP but I need to use in my Login/Register project. $con = mysqli_connect("***", "***", "***", "***"); $name = $_POST["name"]; $username = $_POST["username"]; $password = $_POST["password"]; $statement = mysqli_prepare($con, "INSERT INTO user (name, username, password) VALUES (?, ?, ?)"); mysqli_stmt_bind_param($statement, "siss", $name, $username, $password); mysqli_stmt_execute($statement); $response = array(); $response["success"] = true; echo json

I can upload to server “Fatal error: Uncaught Error: Call to undefined function fetch_assoc()” etc [duplicate]

匆匆过客 提交于 2020-01-11 14:48:49
问题 This question already has answers here : Understanding fetch_assoc() (1 answer) Fatal error: Call to undefined function fetch_assoc() What Gives? (2 answers) mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it? (1 answer) Reference - What does this error mean in PHP? (36 answers) Closed 10 days ago . I am currently making a comment section with two tables. One is the main comment section, I can comment and it

I can upload to server “Fatal error: Uncaught Error: Call to undefined function fetch_assoc()” etc [duplicate]

让人想犯罪 __ 提交于 2020-01-11 14:48:09
问题 This question already has answers here : Understanding fetch_assoc() (1 answer) Fatal error: Call to undefined function fetch_assoc() What Gives? (2 answers) mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it? (1 answer) Reference - What does this error mean in PHP? (36 answers) Closed 10 days ago . I am currently making a comment section with two tables. One is the main comment section, I can comment and it

Use Of Undefined Constant in script

*爱你&永不变心* 提交于 2020-01-11 14:44:30
问题 I've searched the site and saw fixes for the issue in which the user should have put single quotes around the variable but I still a bit confused. Errors: (all refer to line 28) Notice: Use of undefined constant log_id - assumed 'log_id' Notice: Use of undefined constant log_username - assumed 'log_username' Notice: Use of undefined constant log_password - assumed 'log_password' Script: <?php session_start(); include ("includes/connection.php"); $user_ok = false; $log_id = ""; $log_username =

show name from inner join with the id [duplicate]

∥☆過路亽.° 提交于 2020-01-11 14:38:27
问题 This question already has answers here : inner join between 3 tables (3 answers) Closed 2 years ago . i have this query : select * from countrysegments inner join country on countrysegments.country_id = country.id inner join segments on countrysegments.segment_id = segments.id all i need to know is how to show the name of the country inside table country, and for each country show all the segments available,nothing worked with me, if someone could help me would me great, thank u i tried a lot

Count always returns 1…but does it exist?

点点圈 提交于 2020-01-11 14:08:09
问题 I'm trying to check if a file name already exists in the "reviews" column within a particular category, before it's created. If it already exists, I want to add today's date to the name to make it a unique filename. I can't seem to find if it exists using count. When I echo $checkfile, it always returns 1, whether the file exists or not. $today = date("Y-m-d"); $list = service_category; $php_file_name = $last."_".$first.".php"; $check = mysqli_query($sqli, "SELECT count(reviews) FROM table

MySQL Decimal DataType - Truncating Insert Values With Commas?

前提是你 提交于 2020-01-11 13:49:11
问题 I have a MySQL field that is of the type Decimal(12,2). Upon using the following query to get an insert, I'm not getting the correct value stored. INSERT INTO table (someValue) VALUES ('1,200'); This, instead of displaying "1200.00" in the decimal field "someValue", is displaying "1.00" - truncating the data after the first comma. My questions are, why does MySQL have this behavior, and is there a simple way to get around it? 回答1: if your value is read from some HTML form and you can't avoid

Pagination keeps showing the same portion of SQL data

蹲街弑〆低调 提交于 2020-01-11 13:43:08
问题 I have a really large data set from SQL that i need to paginate. I have an issue with my pagination code. The code does show the page number in the URL and it does give me pagination hyperlinks at the bottom of the table. However, any page I click on, it outputs the same exact portion of the sql datatable. Also, I'm doing this in wordpress. // define how many results you want per page $results_per_page = 10; // find out the number of results stored in database $sql='SELECT * FROM ETF';

Is there a way to demonstrate SQL injection with mysqli?

只愿长相守 提交于 2020-01-11 13:26:09
问题 I want to make a quick and easy demonstration about how SQL injection work. And I've solved some of my problems. I have a table with random usernames, passwords and emails in, and I'm able to "inject" SQL code to view all of the users in a search with this injection: ' OR '1'='1 This is how my PHP code looks for searching for "members": if (isset($_POST['search'])) { $searchterm = $_POST['searchterm']; echo $searchterm . '<br>'; /* SQL query for searching in database */ $sql = "SELECT