Jump to content

Recommended Posts

Hi, I'm having troubles with my variable i guess :/

 

This is some of my code:

<?PHP
$brugernavn = mysql_real_escape_string($_POST['brugernavn']); 

$checkbruger = mysql_query("SELECT brugernavn FROM kunder WHERE brugernavn=('$brugernavn')");


//$user_exists=mysql_query("SELECT username FROM table WHERE username='$username'");
if(mysql_num_rows($checkbruger)>0)
{
    // Config
      $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.doc','.docx','.xls','.xlsx','.pdf');

$result = mysql_query("SELECT * FROM indstillinger LIMIT 1");
$row = mysql_fetch_array($result);

$max_filesize = $row["uploadsize"];
$upload_path = "../kundedata/' . $brugernavn . '/";

   $filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension).
   $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.

 

I think my problem is the $brugernavn variable in the upload path, but if i'm not able to write it like that, how else would i do it?

Link to comment
https://forums.phpfreaks.com/topic/208661-uploading-files/
Share on other sites

$checkbruger = mysql_query("SELECT brugernavn FROM kunder WHERE brugernavn=('$brugernavn')");

 

why is $brugernavn in brackets? it could simply be:

$checkbruger = mysql_query("SELECT brugernavn FROM kunder WHERE brugernavn='$brugernavn'");

 

although that query seems to simply loop round on itself and find the variable you have already got.

Link to comment
https://forums.phpfreaks.com/topic/208661-uploading-files/#findComment-1090116
Share on other sites

When i try to upload a test file it says i need to chmod the folder.

This is being tested on windows, and the folder already exists. Error didn't appear when i had

$upload_path = "../kundedata/";

 

The query is there to check if the user exists :)

 

And i dunno why it's in brackets :/ It works for me like that lol..

Link to comment
https://forums.phpfreaks.com/topic/208661-uploading-files/#findComment-1090118
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.