Handsome_devil
Handsome_devil

Reputation: 27

Insert into php database

I am trying to insert into a table media and a column membro, a member name when he is logged in and he has uploaded an image/video, with no luck, this is my code that I put in submit.php:

<?php $fbme = $_SESSION['jigowatt']['username'];?>
<?php if (!isset($_SESSION)) session_start();
    if(isset($_SESSION['jigowatt']['username'])) {
    mysqli_query("INSERT INTO media (membro) values ('$fbme')");
}?> 

I don't like to waste your time as I love this site, but some tips will be thanked.

Upvotes: 0

Views: 137

Answers (3)

Noor
Noor

Reputation: 1391

Start session at the start of the code and the use session after that

     <?php if (!isset($_SESSION)) session_start(); ?>
       <?php $fbme = $_SESSION['jigowatt']['username'];?>

Upvotes: 1

Daryl Gill
Daryl Gill

Reputation: 5524

Try turning on your session so it can be accessed:

session_start();

Throw this at the top of your page, unles you already have it on an include further up the page. If you already have; Everything looks in order from a first glimpse, if there is an under-laying problem with the MySQLI Driver within your code, try turning on the error reporting

mysqli_report(MYSQLI_REPORT_ALL);

Or even it's because you have not specified the database link:

$DB = new mysqli("","","","");
mysqli_query($DB,"");

Upvotes: 0

Mahmood Rehman
Mahmood Rehman

Reputation: 4331

Try your code with little difference like this :

<?php
if (!isset($_SESSION)) session_start();
 $fbme = $_SESSION['jigowatt']['username'];?>
<?php 
if(isset($_SESSION['jigowatt']['username'])) {
mysqli_query("INSERT INTO media (membro) values ('$fbme')");
}?> 

Upvotes: 1

Related Questions