Jump to content


Photo

check with null


  • Please log in to reply
9 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 21 September 2006 - 02:33 PM

I am creating a file handling script.
If no file was uploaded, or they didn't try I am registering the url, and the name of the file with null for database entry like
$tempfile = "null";
$tempfileurl = "null";
putting that into the database, later can I say
<?php
while ($row = mysql_fetch_array(whatever)) {
  if ($tempfile != "null") {
    // do what is necessary to show the file
  }else {
    // act like the file was never there
   }
}
?>
would thatr work in testing for the file??

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 jvrothjr

jvrothjr
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts
  • LocationOhio

Posted 21 September 2006 - 02:34 PM

<?php
while ($row = mysql_fetch_array(whatever)) {
  if ($tempfile != Null) {
    // do what is necessary to show the file
  }else {
    // act like the file was never there
   }
}
?>

If you understand everything you know nothing!

http://rcchjr.awardspace.com/

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 September 2006 - 02:41 PM

would thatr work in testing for the file??


why not try it and then come to us if you are having problems? a good portion of learning is simply trial and error with things like this.

as a side note, if you're looking to see whether a file has been uploaded, simply check out the function file_exists().
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 21 September 2006 - 02:43 PM

It would better to construct a IF() in your SELECT part of the query and return some flag from the test, than to use NULL in your db table. It's really a bad idea to use NULL in a database, if you don't understand why, then you need to do some reading!

me!

#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 September 2006 - 02:50 PM

It's really a bad idea to use NULL in a database, if you don't understand why, then you need to do some reading!

sounds like you need to do a little more reading yourself ;) ... yes, there are some valid arguments why NULL shouldn't be used in some cases, but there are also valid arguments for some cases to use them. as explained in the article, most of the arguments you read are criticism of SQL and how it handles NULL, not of NULL itself. NULL is a valid data form, and when handled properly can be very useful.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#6 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 21 September 2006 - 03:29 PM

I was given the advice about null, from one of the best mysql/database people on the internet right here in this forum, named, fenway, and I doubt if you knew even a quarter of what he knows, so I think I will take his advice on this one.  He gave me advice about this awhile back, and when I finished hte system, and didn't listen to him, I am severely regretting it now, he said "null" is the best one to use(for what I was trying to do), I didn't listen to what he said, and I lost about a week worth of development time.  So I will stick with what he said from now on.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#7 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 21 September 2006 - 03:35 PM

If you think it's good to use, then I am happy for you! But because it over used and used most times out of context, (used without knowing what it really does) it should never be used! Sorry if my statement offended you, but using null in scripting is totally different than * NULL -> unknown * in your database logic!


me!

#8 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 21 September 2006 - 03:43 PM

I dont' really get offended but

if you don't understand why, then you need to do some reading!

That was slightly more than annoying, but I suppose I can understand where your coming from.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#9 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 21 September 2006 - 03:50 PM

I dont' really get offended but

if you don't understand why, then you need to do some reading!

That was slightly more than annoying, but I suppose I can understand where your coming from.


I guess I should have been clearer, that statement did sound sort of lame, sorry, I will try better to explain myself next time!


me!

#10 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 21 September 2006 - 03:59 PM

Ok, I will do some research on null.  And see what all it says about it.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users