mysqli

Warning: mysqli_num_rows() expects exactly 1 parameter, 2 given | mysql |mysqli

好久不见. 提交于 2019-12-31 05:26:07
问题 i have code like this in mysql_query , works fine. but i moving all the code to mysqli_ its throw error like in the title mysql $count = mysql_query("SELECT COUNT(*) FROM xxx limit 2") or die(mysql_error()); $count = mysql_result($count,0); for($i=0; $i<$count;$i++){ echo '<li data-target="#transition-timer-carousel" data-slide-to="'.$i.'"'; if($i==0){ echo 'class="active"'; } echo '></li>'; } mysqli $count = mysqli_query($con,"SELECT COUNT(*) FROM xxx limit 2") or die(mysqli_error()); $count

Having a issue with php statement using loop mysqli

狂风中的少年 提交于 2019-12-31 05:18:06
问题 Hello Please forgive me if I'm not asking this right. I have the following code. <?php //Connect to mysql server include ("Data.php"); if (!$con) { die ("connection error". mysqli_connect_error()); } $sql1 = "SELECT * FROM PMList where AssetNum= '$AssetNum' and Plant= '$Plant';"; $result = mysqli_query($con, $sql1) or die(mysqli_error($con)); if ($result->num_rows > 0) $count = 0; $Task = 1; while($row = mysqli_fetch_array($result)) { $Task++; echo "<td bgcolor='#D8D8D8' align='Left'>"; echo

undefined function mysqli_stmt_init() php error

冷暖自知 提交于 2019-12-31 04:45:31
问题 I'm new to using php mysqli prepared statements. No matter what I try I always get this error message. Fatal error: Call to undefined function mysqli_stmt_init() in...(etc) I have close my database link further below in my code, it isn't show here. Here is my code: $link = mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database); if (mysqli_connect_errno()) { echo 'We\'re having problems connecting right now. Please try again later.'; exit(); } $email_query = mysqli_stmt

MySqli: is it possible to create a database? [closed]

久未见 提交于 2019-12-31 04:33:07
问题 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 6 years ago . I've been sifting through the MySQLi docs, and as far as I can tell, I there's no way to create a database using PHP and MySQLi. Is this correct? 回答1: The CREATE DATABASE statement is used to create a database in

How to insert values in a PHP array to a MySQL table?

隐身守侯 提交于 2019-12-31 03:57:09
问题 I am creating a registration form, with fields for Name, Email and Phone Number. To check the validity of user input, I have a function validate_input() that returns an array $arr containing input entered by the user (if user input is valid). $arr is then passed to a separate function that inserts the values in arr into a MySQL table user containing fields for name , email and phone . I initially tried the following: $insert_query = "INSERT INTO user (name, email, phone) VALUES ('$arr['name']

how can I creates a mysqli database for first the first time?

笑着哭i 提交于 2019-12-31 02:49:30
问题 I was running an example from a mysqli tutorial. $mysqli = new mysqli("localhost", "user", "password", "database"); if($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ) " . $mysqli->connect_error;} echo $mysqli->host_info . "\n"; } I was getting the error: Warning: mysqli::mysqli(): (42000/1049): Unknown database 'world' in /home/... What should I do to create the database? 回答1: You have to use this: $mysqli=new mysqli("localhost","user","password")

Ensuring MySQL connection works in PHP function

别说谁变了你拦得住时间么 提交于 2019-12-31 01:57:08
问题 I have code with the following form: <?php function doSomething{ //Do stuff with MySQL $con->tralalala(); } $con = connectToDatabase;//This would actually be a line or two. doSomething(); ?> This (type of) code doesn't work, because doSomething() doesn't have a connection to the database. Can anyone explain why not? I create the $con connection before I call doSomething(). So why does the function act as if there's no connection? Is there any way to fix this, short of passing the connection

Using fetch_assoc on prepared statements (php mysqli)

懵懂的女人 提交于 2019-12-30 18:43:49
问题 I'm currently working on a login script, and I got this code: $selectUser = $db->prepare("SELECT `id`,`password`,`salt` FROM `users` WHERE `username`=?"); $selectUser->bind_param('s', $username); $selectUser->execute(); if ($selectUser->num_rows() < 0) echo "no_user"; else { $user = $selectUser->fetch_assoc(); echo $user['id']; } Here's the error I get: Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() I tried all sorts of variations, like: $result = $selectUser

What the different between MySQL Native Driver and MySQL Client Library

做~自己de王妃 提交于 2019-12-30 18:25:55
问题 I want to know the different between MySQL Native Driver and MySQL Client Library and when to use both of them 回答1: There is no big difference in the PHP language level. libmysqlclient distributed by MySQL, mysqlnd distributed by PHP. libmysqlclient is part of MySQL, you need install MySQL library. Their license are different. mysqlnd supports a lot of plugins (mysqlnd_ms & mysqlnd_qc & ...). Because mysqlnd is part of PHP, its memory could be limited by PHP configuration. mysqlnd is the

PHP mysqli - return an associative array from a prepared statement

孤者浪人 提交于 2019-12-30 17:32:11
问题 I'm trying to use mysqli to prepare a statement in order to safely pass in variable values to the query. All of that is working for me, but the problem I'm running into is getting the result in an associative array. Here's my structure so far: $query = $c->stmt_init(); $query->prepare("SELECT e._id,e.description,e.eventDate,e.eventTime,e.address,e.locationDescription,i.guestId,r.guestId IS NOT NULL AS 'RSVP-ed' FROM eventList AS e JOIN inviteList AS i ON e._id = i.eventId LEFT JOIN rsvpList