mysqli

MySQL vs MySQLi when using PHP [closed]

谁都会走 提交于 2020-01-08 08:45:28
问题 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 7 years ago . Which is better, MySQL or MySQLi? And why? Which should I use? I mean better not just in terms of performance, but any other relevant

Fatal error: Call to undefined function fetch_assoc() What Gives?

旧时模样 提交于 2020-01-08 06:26:47
问题 Im trying to display users from the database on the page after login but i keep getting an error message: Fatal error: Call to undefined function fetch_assoc() here is the code: <?php session_start(); ?> <link rel="stylesheet" href="form.css"> <div class="body content"> <div class="welcome"> <div class="alert alert-success"><?= $_SESSION['message'] ?></div> <img src="<?= $_SESSION['avatar'] ?>"><br /> Welcome <span class="user"><?= $_SESSION['username'] ?></span> <?php $mysqli = new mysqli(

Fatal error: Call to undefined function fetch_assoc() What Gives?

不问归期 提交于 2020-01-08 06:26:37
问题 Im trying to display users from the database on the page after login but i keep getting an error message: Fatal error: Call to undefined function fetch_assoc() here is the code: <?php session_start(); ?> <link rel="stylesheet" href="form.css"> <div class="body content"> <div class="welcome"> <div class="alert alert-success"><?= $_SESSION['message'] ?></div> <img src="<?= $_SESSION['avatar'] ?>"><br /> Welcome <span class="user"><?= $_SESSION['username'] ?></span> <?php $mysqli = new mysqli(

How do I convert this PDO code to MySQLi?

无人久伴 提交于 2020-01-07 09:57:49
问题 I'm quite new to PHP and MySQL and I try to learn how to change a code from PDO to MySQLi. Its about a remember me function with a securitytoken and identifier for a login system that I found in the web. I would like to learn and understand how I can change the code from PDO to MySQLi. I know in MySQLi there is a statement create and prepare, also I have to bind parameters and execute. But in this case, I don't know how to start anyway. $pdo = new PDO('mysql:host=localhost;dbname=dbname',

I want to implement something that doesn't allow the user to rate more than once

天大地大妈咪最大 提交于 2020-01-07 09:28:17
问题 I have used someone else's code that uses the ipaddress way. However, I would like to use a code that checks for the current userid and the id number. $ipaddress = md5($_SERVER['REMOTE_ADDR']); // here I am taking IP as UniqueID but you can have user_id from Database or SESSION /* Database connection settings */ $con = mysqli_connect('localhost','root','','database'); if (mysqli_connect_errno()) { echo "<p>Connection failed:".mysqli_connect_error()."</p>\n"; } /* end of the connection */ if

Can't Get Simple SQL Insert to Work

心已入冬 提交于 2020-01-07 09:18:08
问题 <?php include_once("database.php"); ?> <?php include_once("header.php"); ?> <?php if ($_POST['submit'] ) { $food_name = $_POST['food_name']; $food_calories = $_POST['food_calories']; echo $food_name . $food_calories; if (!empty($food_name) && !empty($food_calories) ) { $query = 'INSERT INTO foods VALUES(0, $food_name, $food_calories)'; mysqli_query($con, $query) or die(mysqli_error($con)); echo 'added'; } else {echo'fail';} } else {echo'fa2oo';} ?> <h1> Please Fill out Form Below to Enter a

Invalid arguments passed join()

筅森魡賤 提交于 2020-01-07 09:02:31
问题 So I made this script that should fetch an array using mysqli_fetch_array and mysqli_query it all works fine, and no error shows up, but then after I change something, using another function, for example, If I change the mood, nickname or whatever, it shows an error Warning: join(): Invalid arguments passed in Main.php on line 526 Iv'e been trying to fix this using a while loop and the same thing happens $info = mysqli_fetch_array(mysqli_query($con, "SELECT id, nickname, mood, credits, colour

Invalid arguments passed join()

断了今生、忘了曾经 提交于 2020-01-07 09:02:10
问题 So I made this script that should fetch an array using mysqli_fetch_array and mysqli_query it all works fine, and no error shows up, but then after I change something, using another function, for example, If I change the mood, nickname or whatever, it shows an error Warning: join(): Invalid arguments passed in Main.php on line 526 Iv'e been trying to fix this using a while loop and the same thing happens $info = mysqli_fetch_array(mysqli_query($con, "SELECT id, nickname, mood, credits, colour

Return results within a given radius using a bounding circle as a 'First Cut' in MySQL

狂风中的少年 提交于 2020-01-07 08:56:13
问题 I was working with Chris Veness' scripts from http://www.movable-type.co.uk I was trying to run a query against a MySQL database to return only rows that fall within a given radius, using his Bounding Circle script. As follows: <?php require 'inc/dbparams.inc.php'; // defines $dsn, $username, $password $db = new PDO($dsn, $username, $password); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); $lat = $_GET['lat']; // latitude of centre of bounding circle in degrees $lon = $_GET

Inserting values into a table within a function receives an error, but when trying to insert values into the table outside of a function it works fine

独自空忆成欢 提交于 2020-01-07 08:40:43
问题 So this method works in inserting values to the table: $link = mysqli_connect("example.com","a","b","c"); $sql = 'INSERT INTO `table` (`field1`, `field2`) VALUES ("foo", "bar");'; mysqli_query($link, $sql); However, this method fails: $link = mysqli_connect("example.com","a","b","c"); function foobar(){ $sql = 'INSERT INTO `table` (`field1`, `field2`) VALUES ("foo", "bar");'; mysqli_query($link, $sql); } And this gives the error: Warning: mysqli_query() expects parameter 1 to be mysqli, null