1

Hi I have a script to log people into my site and within the script is this method (I have changed the values)

$con=mysql_connect("mydbdomain", "mydbusername", "mypassword");

Now I downloaded a open source file upload program and uploaded it to my server and only allow users who are in the database to use it. It all works great. I however then go and edit the php code which handles the file uploads so that every time a user uploads a file it goes into a directory that matches their username.

<?php
/*
* jQuery File Upload Plugin PHP Class 7.1.4
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*
* Modified by leathan AxE
*/

class UploadHandler
{
...
...
...
...
    function foo() { ... }
}
?>

The function above named foo is where i connect to the db and extract the value of the future directory. But whenever i have this line.

$con=mysql_connect("mydbdomain", "mydbusername", "mypassword");

instead of

$con=@mysql_connect("mydbdomain", "mydbusername", "mypassword");

nothing works. why is it when i use @ and suppress errors it all works? Why are there errors? The files are uploaded into the usernames directory perfectly only when using @. I just want to understand what is happening. I dont understand how there can be an error because i use the line

$con=mysql_connect("mydbdomain", "mydbusername", "mypassword");

in other files and it always works.

mleko
  • 9,108
  • 5
  • 41
  • 68
Banned_User
  • 837
  • 2
  • 9
  • 16
  • Check error log and post what you find there – mleko May 18 '14 at 08:46
  • This is what makes me extra mad. On my local machine I dont need to use @ because there are no errors. But when uploaded to 1and1 webhosting I need to use @. How can I check the error.log in 1and1 hosting? I dont think they allow me... ? – Banned_User May 18 '14 at 08:50
  • phpinfo() gives no value for error_log and ls ~/log gives No such file or directory. and no access to php.ini. also find / -regex 'blabla' gives pure permission denied :/ so no luck searching. I dont think I have access. can I redirect errors to a file of my choosing within a script to find out? – Banned_User May 18 '14 at 08:54
  • @ means you don't need any types of error messages - don't use mysql_connect because it is depreciated function - see http://stackoverflow.com/questions/11742824/mysql-connect-and-mysql-connect – Mohammad Alabed May 18 '14 at 09:03
  • Yes I was aware. :) Tnx tho.. The code is from 9 years ago :) adding @ is fine for now. – Banned_User May 18 '14 at 09:41

1 Answers1

3

mysql_connect is deprecated and shouldn't be used. Probably your provider have E_DEPRECATED error level and you get warning whenever you use mysql_connect.

Try using PDO

mleko
  • 9,108
  • 5
  • 41
  • 68
  • I was aware it was depreciated but am far to lazy! I just wanted to understand what was happening I have now learned about E_DEPRECATED! That is EXACTLY the what was happening!!!!! THANK YOU!!! – Banned_User May 18 '14 at 08:59