Jump to content

[SOLVED] Inserting Username into MySql Table Row


larry777

Recommended Posts



Greetings,    I'm trying to post the username into a table row...  I can't get it to work!!!  : ( 
Not sure what I'm doing wrong..  can you help...??  I'm banging my head against my desk!

Cheers.


***************************************

$sql = "INSERT INTO filestore SET
      filename = '$uploadname',
      mimetype = '$uploadtype',
      description = '$uploaddesc',
      filedata = '$filedata',
      username = $_SESSION['MM_Username']
  ";


***************************************
You can't use the associative array call from within quotes, try this:

$sql = "INSERT INTO filestore SET
      filename = '$uploadname',
      mimetype = '$uploadtype',
      description = '$uploaddesc',
      filedata = '$filedata',
      username = '".$_SESSION['MM_Username']."'";


[i]Edit: forgot the ticks around the username.[/i]
They're in there now.  I edited it about 20 seconds after I posted.  I was just saying why I edited.

If $_SESSION['MM_Username'] = Joe then the query will be $sql = " ....... username = 'Joe' ".  There should be ticks around the variable call in case the Username has spaces in it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.