mysqli

php form: cannot update the database, query with multiple join

▼魔方 西西 提交于 2019-12-25 08:58:25
问题 EDIT#2: SQLfiddle EDIT#1: i see everything in fields now, but cannot update. all queries by themselves work. I have a page that must show information from database for update. The query has multiple join. The query itself works. I do not get error message(and the usual methods in order to get a hidden or disabled error message do not work), so I do not know what is wrong, but the form is blank and doesn't edit anything(sometimes blank forms edit information to empty fields). I've had similar

Mysqli_num_rows not working correctly [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-25 08:58:16
问题 This question already has an answer here : 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) Closed last month . I have a POST php script that I'm wanting to check if the POST data already exists in the database and if it does, throw error message, if it doesn't add it to database and give success message. It adds successfully but if I try and add a name that already exists, it gives error: Warning:

php statement question. (mysqli)

流过昼夜 提交于 2019-12-25 08:42:19
问题 $db = new mysqli('localhost','root','nere','deneme'); if ($db->error) exit(); $stmt = $db->prepare("INSERT INTO deneme VALUES (?,?,?)"); $stmt->bind_param('ssi',$adi,$soyadi,$no); $adi='recep'; $soyadi='saban'; $no=5; $stmt->execute(); i got error. Fatal error: Call to a member function bind_param() on a non-object in C:\wamp\www\rock\index.php on line 10 what I am doing wrong? 回答1: it should be something like below. Also you should assign the values to the variables before passing it to bind

Prepared Statement for sessions

早过忘川 提交于 2019-12-25 08:29:28
问题 I've finally decided to start using prepared statements. Though, i am 50/50 on whats correct and not. I'm trying to make a login page with the prepared statements. Though, it seems like it doesn't retrieve any session value except the username $_SESSION Here's my code: $username = $_POST['username']; $password = md5($_POST['password']); $sql = "SELECT * FROM users WHERE BINARY username=? AND BINARY password=?"; if($stmt = $db->prepare($sql)){ $stmt->bind_param("ss",$username,$password); $stmt

How to convert a mysqli query to $wpdb in wordpress?

 ̄綄美尐妖づ 提交于 2019-12-25 08:03:17
问题 I want to use $wpdb query instead of mysqli for my wordpress table. The wordpress table in question as follows : wp_example +----+---------------------+------+ | id | name | age | +----+---------------------+------+ | 1 | Sandy Smith | 21 | | 2 | John Doe | 22 | | 3 | Tim Robbins | 28 | | 4 | John Reese | 29 | | 5 | Harold Finch | 20 | +----+---------------------+------+ The mysqli query which I would like to be in $wpdb: <?php // Make a MySQL Connection $query = "SELECT * FROM wp_example";

Getting results of statement

让人想犯罪 __ 提交于 2019-12-25 08:00:02
问题 I have made this example code: $db = new mysqli("localhost","root","password","xxx"); $statement = $db->prepare("SELECT name, password FROM persons WHERE name=? LIMIT 1"); $statement->bind_param('s', "kevin"); $statement->execute(); if($statement->num_rows){ $statement->bind_result($dbname, $dbpassword); $statement->free_result(); }; echo $dbname; echo $dbpass; How can use/get $dbname and $dbpassword directly without using something like: while($statement->fetch()){ echo $dbname; } I want to

fetching user data with prepared statement

瘦欲@ 提交于 2019-12-25 07:59:36
问题 hey guy so am trying to create profile table by displaying user data. have used some code samples that you'll see in the code below, have commented some out so watch out. here is my code // $stmt = $con->prepare("SELECT * FROM user WHERE id = ? "); // $stmt->bind_param('s', $id); // if($stmt->execute()){ // //$result = $stmt->get_result(); // if($result->num_rows > 0){ // // username exists // //$stmt->bind_result($firstname, $lastname, $user_type, $email, $profession); // echo 'No Data Found

Geolocation LONG/LAN in database [closed]

折月煮酒 提交于 2019-12-25 07:55:16
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I wrote php code to add adresses to a database. Then I wrote a script to read the long/lan from this adressen and store them in the DB. At this moment there are 10 items in the DB but when i add the 12th or 13th,

mysqli - handling errors with transactions

假如想象 提交于 2019-12-25 07:48:23
问题 How to properly handle errors with transactions and prepared statements when using mysqli? Snippet: <?php $conn = require_once 'dbconn.php'; $conn->autocommit(FALSE); $stmt_ins_option = $conn->prepare('INSERT INTO options(option_name) VALUES(?)'); $option_name = 'foo'; $stmt_ins_option->bind_param('s', $option_name); $stmt_ins_option->execute(); $conn->commit(); if($conn->errno) { $conn->rollback(); echo $conn->error; } It won't add it a second time because there's a UNIQUE constraint on that

Pass session variable to new page when link is clicked

烈酒焚心 提交于 2019-12-25 07:29:11
问题 I'm having a bit of trouble with this. I have a search results page of books with various links, all linking to the same page (book.php) and I want to set a session variable to pass through to the new page which should display more info about the specific result link that is selected. I am trying to pass the variable $_SESSION['booktitle'] through to book.php when the link in the while loop is selected. The code of the search results page is: <form id="rform" name="formsort" action="" method=