Jump to content

Object of class mysqli_result could not be converted to string


yami
Go to solution Solved by Barand,

Recommended Posts

$resulti = mysqli_query($connection , "INSERT INTO cart(idItem,idUser) VALUES('$idd','$iduser')");
				
					if(!$resulti){
						die('Query failed!' . mysqli_error($connection));
					  }

I am just trying to insert some data into a db table but this error keeps showing..any ideas how to fix it?

Link to comment
Share on other sites

Are you sure about the line?  I don't see any attempt to convert a var unless it is the two Values in your query statement.  Try separating the query build from the query call and see what happens.

$q  =......

mysqli__query($connection, $q);

Link to comment
Share on other sites

So I have an if-else statement full of queries and it is the else part where there is an error and here it is:

else{
				$nameuser = $_SESSION['username'];
				$iduser = $connection->query("SELECT idCustomer FROM customer WHERE username='$nameuser'");
				if(!$iduser){
					die('Query failed!' . mysqli_error($connection));
				  }

				if (isset($_POST['idd']) && $_POST['idd']!=""){
					$idd = $_POST['idd'];
				// echo $idd;
			
	
				// $query ="INSERT INTO cart(idItem,idUser) VALUES('$idd','$iduser')";
				$resulti = mysqli_query($connection , "INSERT INTO cart(idItem,idUser) VALUES('$idd','$iduser')");
				
					if(!$resulti){
						die('Query failed!' . mysqli_error($connection));
					  }
				

			}
		}
<input type='hidden' name='idd' id='idd' >

the exact error message: Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\wamp64\www\index.php on line 134

it is the last query's line

is it enough?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.