1 0 Tag Archives: php
post icon

Php error URL file-access is disabled in the server configuration

If your have ever got this error:

URL file-access is disabled in the server configuration

Using php functions like fopen, getimagesize it’s because your using a absolute path. It’s a security thing so that people can’t run scripts to open files on other servers other than there own. You can change this by configuring the php.ini file. But I wouldn’t.

Leave a Comment
post icon

Understanding How Joins Work

Mike Nixon sent me this link that does a pretty sweat job of describing how the different types of joins work when playing with a database.

Leave a Comment
post icon

Deleting a file in php using unlink

Tonight I was having troubles deleting a file from a directory in an application I am working on. It kept deleting the entry in the table but not the actual file from the directory. Here is what the code looked like:

< ?php
$sql = "DELETE FROM uploads WHERE upload_id = $id";
$result = mysql_query($sql);
//if it ran ok
if (mysql_affected_rows() == 1) {
 delete the file from the uploads dir
 unlink('uploads/'$row['file_name']);
}
?>

I couldn’t figure out for the life of me then I tried this:

< ?php
//delete the file from the uploads dir
unlink('uploads/' . $row['file_name']);
$sql = "DELETE FROM uploads WHERE upload_id = $id";
$result = mysql_query($sql);
//if it ran ok
if (mysql_affected_rows() == 1) {
 //do something
}
?>

It worked perfect! I just had to seperate the name ($row['file_name']), which could also be a variable with a space: ‘uploads/’ . I also had to make sure the unlink was before the DELETE query because if it was after the query it would be trying to delete something that wasn’t there.

Leave a Comment
31. Mar, 2007
post icon

Creating a email form using actionscript and php

I just finished an email form that I put up on my contact page. It was an assignment for my Actionscript class. I used Actionscript to import and place the components, validate, and send data using a LoadVars function to a php script, which then sends off an email to myself. This was the first time I used Actionscript and PHP together and I’m stoked on what you can do with it. My minds really starting to buzz and I can’t wait to learn more.

Leave a Comment
post icon

A Simple Birthday Calculator

I’ve always had a problem with knowing ahead of time what day my birthday was going to be on. Like if it was on a FRIDAY or SATURDAY, so that I could party. So HERE is a cool application that I just did in my php class. It takes your input and tells you what day it’s on. No more guessing if your going to be calling into work sick! Just kidding, computer geeks don’t party? Right?

Leave a Comment