Php Mysql Image upload

<?php  

// 1. Gem modtagne formulardata i variabler:  
$navn = $_POST['navn'];  
$alder = $_POST['alder'];  
$postnr = $_POST['postnr'];  
$mail = $_POST['mail'];  
$billede = $_FILES['profilbillede'];  
$password = $_POST['password'];  



// 2. Forbind til databasen:  
$databaselink = mysqli_connect("localhost","mmddk3e12m8b18", "****", "mmddk3e12m8b18") or die     ("Fejl: Kan ikke etablere forbindelse til database");



$billednavn = billedupload($billede);  
// besked til brugeren om at der er sket en fejl    
if($billednavn == false){  
die("Der skete en fejl under upload af billedet");
}



// 3. Udform insert SQL streng med de modtagne data, og udfør SQL strengen på databasen vha     mysqli_query:  
$query = "INSERT INTO brugere (navn, alder, postnr, mail, password, profilbillede) VALUES ('$navn', '$alder', '$postnr', '$mail', '$password', '$billednavn')";  
$result = mysqli_query($databaselink, $query) or die( "Forespørgslen kunne ikke udføres: " .         mysqli_error($databaselink));  

// 4. luk databasen:  
mysqli_close($databaselink);  

function billedupload($fil){  
if($fil['type']=='image/jpeg' or $fil['type']=='image/png'){  
$tmp_navn = $fil['tmp_name'];  
$filnavn = $fil['name'];  
$target = 'images/' . time() . $filnavn;  
move_uploaded_file($tmp_navn,$target);  
return $target;  
}  
else{  
return false;  
}  
}  

?>
 
Make sure $_FILES is set? Debug it with var_dump($_FILES)and  enctype="multipart/form-data" in your <form> 

Samsung sells 500 handsets per minute

Samsung Electronics, the world leader in mobiles and memory chips, likely earned a quarterly profit of $8.1 billion, as it sold close to 500 handsets every minute and as demand picked up for the flat screens it makes for mobile devices

Yahoo! Axis

A Search Browser

By Yahoo!

Get a smarter, faster and more visual way to search and browse the web!

Yahoo! Axis is a new browser that redefines what it means to search and browse the web on your iPhone, iPad.

Requirements: Compatible with iPhone, iPod touch, and iPad. Requires iOS 5.1 or later. This app is optimized for iPhone 5.

Yahoo! Axis is a desktop web browser extension and mobile browser for iOS devices created and developed by Yahoo!

Since on iOS Axis is essentially running a skin over top of Safari -- similar to what the Atomic browser does. In Yahoo's case, though, it's a powerful skin, filled with features you won't find on Apple's browser, such as easy toggling between regular and image searches, and instant syncing of bookmarks and tabs between desktop, iPhone and iPad.

 

What is Shell Script

Normally shells are interactive. It means shell accept command from you (via keyboard) and execute them. But if you use command one by one (sequence of 'n' number of commands) , the you can store this sequence of command to text file and tell the shell to execute this text file instead of entering the commands. This is know as shell script.

The Role of the Device Driver

As a programmer, you are able to make your own choices about your driver, and
choose an acceptable trade-off between the programming time required and the flexibility
of the result. Though it may appear strange to say that a driver is “flexible,” we
like this word because it emphasizes that the role of a device driver is providing
mechanism, not policy.

The distinction between mechanism and policy is one of the best ideas behind the
Unix design. Most programming problems can indeed be split into two parts: “what
capabilities are to be provided” (the mechanism) and “how those capabilities can be
used” (the policy). If the two issues are addressed by different parts of the program,
or even by different programs altogether, the software package is much easier to
develop and to adapt to particular needs.

For example, Unix management of the graphic display is split between the X server,
which knows the hardware and offers a unified interface to user programs, and the
window and session managers, which implement a particular policy without knowing
anything about the hardware. People can use the same window manager on different
hardware, and different users can run different configurations on the same
workstation. Even completely different desktop environments, such as KDE and
GNOME, can coexist on the same system. Another example is the layered structure
of TCP/IP networking: the operating system offers the socket abstraction, which
implements no policy regarding the data to be transferred, while different servers are
in charge of the services (and their associated policies). Moreover, a server like ftpd
provides the file transfer mechanism, while users can use whatever client they prefer;
both command-line and graphic clients exist, and anyone can write a new user interface
to transfer files.

The kernel


The kernel is a piece of software that, roughly speaking, provides a layer between the hardware and the application programs running on a computer. In a strict, computer-science sense, the term 'Linux' refers only to the kernel - the bit that Linus Torvalds wrote in the early 90s.

The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls.
As an illustration of the way that the shell and the kernel work together, suppose a user types rm myfile (which has the effect of removing the file myfile). The shell searches the filestore for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on myfile. When the process rm myfile has finished running, the shell then returns the UNIX prompt % to the user, indicating that it is waiting for further commands.

Php Directory Functions


  • chdir — Change directory
  • chroot — Change the root directory
  • closedir — Close directory handle
  • dir — Return an instance of the Directory class
  • getcwd — Gets the current working directory
  • opendir — Open directory handle
  • readdir — Read entry from directory handle
  • rewinddir — Rewind directory handle
  • scandir — List files and directories inside the specified path

File Manipulation

11.3. File Manipulation

There may be times when you don't want to store information in a database and may want to work directly with a file instead. An example is a logfile that tracks when your application can't connect to the database. It'd be impossible to keep this information in the database, since it's not available at exactly the time you'd need to write to it. PHP provides functions for file manipulation that can perform the following:
  • Check the existence of a file
  • Create a file
  • Append to a file
  • Rename a file
  • Delete a file

The file_exists.php script checks to see if the file is there
<?php
  $file_name="file_exists.php";

  if(file_exists($file_name)) {
    echo ("$file_name does exist.");
  }
  else {
    echo ("$file_name does not exist.");
  }
?>

As you would expect, the file does exist:
The file exists.php does exist. 
 
PHP provides several functions to tell you about various file attributes. PHP has the ability to read data from, and write data to, files on your system. However, it doesn't just stop there. It comes with a full-featured file-and-directory-manipulation API that allows you to:
  • View and modify file attributes
  • Read and list directory contents
  • Alter file permissions
  • Retrieve file contents into a variety of native data structures
  • Search for files based on specific patterns
All of this file manipulation through the API is robust and flexible. These characteristics are why we're writing this book. PHP has a lot of great commands, including all the file manipulation ones.
11.3.1.1. Permissions
Now that you know a file exists, you may think you're done, but you're not. Just because it's there doesn't mean you can read, write, or execute the file. To check for these attributes, use is_readable to check for read access, is_writable to check for write access, and is_executable to check for the ability to execute the file. Each function takes a filename as its parameter. Unless you know the file is in the same directory as your script, you must specify a full path to the file in the filename. You can use concatenation to put the path and filename together, as in:
$file_name = $path_to_file . $file_name_only; 
                                  
 
 
 
 

Including and Requiring PHP Files

To make your code more readable, you can place your functions in a separate file. Many PHP add-ons that you download off the Internet contain functions already placed into files that you simply include in your PHP program. However, PHP provides four functions that enable you to insert code from other files.
  • include
  • require
  • include_once
  • require_once
All the include and require functions can take a local file or URL as input, but they cannot import a remote file. require and include functions are pretty similar in their functionality except for the way in which they handle an irretrievable resource. For example, include and include_once provide a warning if the resource cannot be retrieved and try to continue execution of the program. The require and require_once functions provide stop processing of the particular page if they can't retrieve the resource. Now we're going to get more specific about these four functions.

Defining Functions

There are already many functions built into PHP. However, you can define your own and organize your code into functions. To define your own functions, start out with the function statement:
function some_function([arguments]) { code to execute }

The brackets ([ ]) mean optional. The code could also be written with optional_arguments in place of [arguments]. The function keyword is followed by the name of the function. Function names abide by the same rules as other named objects such as variables in PHP. A pair of parentheses must come next. If your function has parameters, they're specified within the parentheses. Finally, the code to execute is listed between curly brackets, as seen in the code above.
You can define functions anywhere in your code and call them from virtually anywhere. Scope rules apply. The scope of a variable is the context within which it's defined. For the most part, all PHP variables have only a single scope. A single scope spans included and required files as well. The function is defined on the same page or included in an include file. Functions can have parameters and return values that allow you to reuse code.
To create your own function that simply displays a different hello message, you would write:
 
<?php
function hi()
{
  echo ("Hello from function-land!");
}
//Call the function
hi();
?>

which displays:
Hello from function-land!