Update Command Not working mysqli [duplicate] - php

This question already has answers here:
Are you allowed to use numbers as table names in MySQL?
(5 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
<?php include('header.php');
include('config.php');
if (isset($_POST['submit']))
{
$link1=mysqli_real_escape_string($cone,$_POST['link1']);
$link2=mysqli_real_escape_string($cone,$_POST['link2']);
$link3=mysqli_real_escape_string($cone,$_POST['link3']);
$link4=mysqli_real_escape_string($cone,$_POST['link4']);
$link5=mysqli_real_escape_string($cone,$_POST['link5']);
$sql = "update path set 1='hello' where id=1";
if (mysqli_query($cone,$sql))
{
header("location:section_6.php?done");
}
}
?>
What am i doing wrong here ? The Cone variable is defined in config.php but i can't get the update working and there's no error.

Related

Unable to update item id with username special characters [duplicate]

This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Reference - What does this error mean in PHP?
(38 answers)
UTF-8 all the way through
(13 answers)
Closed 2 years ago.
I'm using paypal buttons as payment, the problem is, when the player type the username, and if have special characters the query don't update item quantity, but with normal name it updates.
{
global $first_name, $last_name, $payer_business_name, $custom,$payer_email;
global $mysql_linklok;
if (($data == "") || ($data == "NOTREQUIRED") || ($user2==""))
{
$key="Could not update user ".$user2;
return (string)$key;
}
$mysql_linklok=mysqli_connect("host","user","pass","db");
if ($mysql_linklok!==false)
{
$query="UPDATE users SET points=points + ".$data." WHERE name=".llipn_quote_smart($user2);
mysqli_query($mysql_linklok,$query);
mysqli_close($mysql_linklok);
}
$key=$data." points added to ".$user2;
return (string)$key;
i've been searching for hours and tried many options, but not of them works.
can someone help me how to solve it?
Many thanks

Problems with MYSQL IN Function PHP [duplicate]

This question already has answers here:
PHP - Using PDO with IN clause array
(9 answers)
Why does this PDO statement silently fail?
(2 answers)
Closed 3 years ago.
I have a little problem with my SQL query:
I have a variable ($arraySearch) with a string:
$arraySearch = "'Bob', 'Ross'";
My PHP query:
$stmt = $this->pdo->prepare("SELECT * FROM `kunden` WHERE `FAMNAME` IN (arraySearch =:arraySearch) AND `VORNAME` IN (arraySearch = :arraySearch)");
$stmt->execute(['arraySearch' => $arraySearch]);
$all = $stmt->fetchAll(PDO::FETCH_CLASS, $model);
Error Code:
Fatal error: Uncaught Error: Call to a member function execute() on boolean
I've been searching for the error for hours but I can't find it.
What am I missing?
Does somebody have any idea?
best regards

PHP MySQL not adding to database [duplicate]

This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
Trying to do a school project, essentially need to take the choice of animal from a dropdown menu, and add the ID of that animal to the order table of the database. dropdown is on a seperate page which works fine, and posts result to this page.
the code:
<?php
include_once("connect-db.php");
if(isset($_POST['Submit'])) {
$choice = $_POST['choice'];
$result = mysqli_query($mysqli, "SELECT * FROM animals WHERE AnimalSpecies=$choice");
while($res = mysqli_fetch_array($result))
{
$id = $res['AnimalID'];
}
$query = mysqli_query($mysqli, "INSERT INTO order('AnimalID') VALUES('$id')");
}
The connectdb file is fine, i have used it in another page. additionally, $choice is working fine, i had it echo manually and it shows the right value. I dont get any error message, it just doesnt add anything to the order table.

"Warning" error PHP [duplicate]

This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Can I mix MySQL APIs in PHP?
(4 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(2 answers)
Closed 5 years ago.
I need help with this:
$query="SELECT productos.id_producto, productos.nombre, productos.precio,
ci.quantity, ci.quantity * productos.precio AS subtotal
FROM productos p
LEFT JOIN cart_items ci
ON ci.id_producto = productos.id_producto";
$com = mysqli_query($cnx, $query);
$row = mysqli_fetch_assoc($com);
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given in "XXXXX" on line 34
In this case is line = 6.
Sorry if this is "simple php" error.
I'm learning PHP.
You have an error on your SQL statement. You've given an alias to your table productos as p but your calling the fields using the table name itself. Try to remove the alias name and you're good to go.
$query="SELECT productos.id_producto, productos.nombre, productos.precio,
ci.quantity, (ci.quantity * productos.precio) AS subtotal
FROM productos
LEFT JOIN cart_items ci
ON ci.id_producto = productos.id_producto";

mysqli_query failed to insert data into table [duplicate]

This question already has answers here:
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(2 answers)
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
I'm trying to insert in to a table video_advert but it's failing,
$result=mysqli_query($db_handle,"INSERT INTO video_advert(title,video,date_out,gender,quantity,room,description) VALUES('".$_POST['adtitle']."','".$imagename."','".$_POST['addate']."','".$_POST['adgender']."','".$_POST['adquantity']."','".$_POST['adroom']."','".$_POST['addescription']."',)");
if($result){
$message1="you are now SignUp";
header("Location:index.php?msid=$message1");
}
else{
echo "not done!";
}
all my field names are correct, but it's returning not done, please help
You have an extra comma after description. Remove it and it will be fine.

Categories