Ninjakreborn Posted September 21, 2006 Share Posted September 21, 2006 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]<?phpwhile ($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?? Quote Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/ Share on other sites More sharing options...
jvrothjr Posted September 21, 2006 Share Posted September 21, 2006 [code=php:0]<?phpwhile ($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] Quote Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/#findComment-96105 Share on other sites More sharing options...
obsidian Posted September 21, 2006 Share Posted September 21, 2006 [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(). Quote Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/#findComment-96109 Share on other sites More sharing options...
printf Posted September 21, 2006 Share Posted September 21, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/#findComment-96112 Share on other sites More sharing options...
obsidian Posted September 21, 2006 Share Posted September 21, 2006 [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. Quote Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/#findComment-96116 Share on other sites More sharing options...
Ninjakreborn Posted September 21, 2006 Author Share Posted September 21, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/#findComment-96130 Share on other sites More sharing options...
printf Posted September 21, 2006 Share Posted September 21, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/#findComment-96131 Share on other sites More sharing options...
Ninjakreborn Posted September 21, 2006 Author Share Posted September 21, 2006 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 Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/#findComment-96133 Share on other sites More sharing options...
printf Posted September 21, 2006 Share Posted September 21, 2006 [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! Quote Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/#findComment-96136 Share on other sites More sharing options...
Ninjakreborn Posted September 21, 2006 Author Share Posted September 21, 2006 Ok, I will do some research on null. And see what all it says about it. Quote Link to comment https://forums.phpfreaks.com/topic/21538-check-with-null/#findComment-96138 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.