Jump to content

check with null


Ninjakreborn

Recommended Posts

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
[code]<?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
  }
}
?>[/code]
would thatr work in testing for the file??
Link to comment
Share on other sites

[quote author=businessman332211 link=topic=108928.msg438755#msg438755 date=1158849183]
would thatr work in testing for the file??
[/quote]

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().
Link to comment
Share on other sites

[quote author=printf link=topic=108928.msg438763#msg438763 date=1158849834]
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!
[/quote]
sounds like [b]you[/b] need to [url=http://www.dbdebunk.com/page/page/1858002.htm]do a little more reading[/url] 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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

[quote author=businessman332211 link=topic=108928.msg438784#msg438784 date=1158853407]
I dont' really get offended but

[quote] if you don't understand why, then you need to do some reading![/quote]
That was slightly more than annoying, but I suppose I can understand where your coming from.
[/quote]

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!
Link to comment
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.