Be kind, I am still learning, I have made this code but it didn't work, I have tried everything, it is suppose to when an user is logged in and someone send an image the member name is recorded at the database:
if (!isset($_SESSION[sforum_.'sforum_logged_in']));
if(isset($_SESSION[sforum_.'sforum_user_username'])) {
mysqli_query(INSERT INTO media (membro) VALUES ('$_SESSION[sforum_.'sforum_user_username']'));
} else {
Echo "erro";
}
It gives an error:
Parse error: syntax error, unexpected T_STRING
You have 2 issues here. You need to quote your SQL in the query, and mysqli_query takes TWO parameters: the connection object link and the sql to run.
mysqli_query($yourDbConnectionString, "INSERT INTO media (membro)
VALUES ('" . $_SESSION[sforum_ . 'sforum_user_username'] . "')");
Obviously substitute $yourDbConnectionString
with the actual value; you didn't include it in the code sample.
Try this code
<?php
if (!isset($_SESSION[sforum_ . 'sforum_logged_in'])) {
if (isset($_SESSION[sforum_ . 'sforum_user_username'])) {
mysqli_query("INSERT INTO media (membro) VALUES ('" . $_SESSION[sforum_ . 'sforum_user_username'] . "')");
} else {
echo "error";
}
}
?>
if(!isset($_SESSION['sforum_logged_in'])) ;
if(isset($_SESSION['sforum_user_username'])) {
$query = "INSERT INTO media(membro) VALUES (`" . $_SESSION['sforum_user_username'] . "`)";
mysqli_query($dbConnect, $query); //$dbConnect is database connected object
}
else {
echo "erro";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.