Jump to content

Cultureshock

Members
  • Posts

    42
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Cultureshock's Achievements

Member

Member (2/5)

0

Reputation

  1. mysql saves it as blank instead of as Null? And I'd like it to be Null if the data provided is left blank?
  2. No, it does; But when a value needs to be NULL, it instead is "" - just blank. Even after using empty() and setting the value to NULL. Mysql saves it as "".
  3. It works fine, but like I said the field won't always need to be emptied. I need a way to update the row, and *if need be* make a field null again. But if the update is simply changed, then the field would not be empty because it would be replaced by the new data.
  4. Can you write something like db_query("..." . (empty($field_data) ? 'NULL' : db_quote($field_data, 'text')) . "..."); Well like I said the field will not always be empty (aka won't need to be null.) If someone removes data they once had, I need it to go back to the way the feild was before trhe first entered any data- Null.
  5. When I save it as is, the mysql data is saved as empty, but not as NULL. I've tried using unset and even $string=NULL, none of which work. The form data I'm saving is to be used on a profile-type page, and if a user doesn't fill out a certain field, I want the data to be saved as NULL. I'm sure the solution is something really obvious. And I can't make the query say field=NULL because the field will not always be empty.
  6. ^ But it IS blank when used in the function I made, even though $boxselected is defined before the function EDIT: I redefined $boxselected inside the function and it works. Is there any other way to do it without redefining the same thing twice?
  7. It works in another page, though. Note: When echoed, it's *NOT* blank.
  8. It's not currently used in any if statements. Thanks though. I looked around a second time to make sure I wasn't writing over it or w/e.
  9. I have a config.php at the top of both pages that contains (amongst other code) <?php $boxselected=$_GET['b']; ?> Now in the files I use $boxselected for a few different purposes but I never change it. (ie it always stays the same info passed in the address bar as ?b=example) However, only in one of the files does $boxselected worked. HOWEVER other lines of config.php ARE working in BOTH pages. Is there any code that would disable $_GET that might be interfering? The page on which $boxselected does NOT work uses a function contained in config.php. But I don't see why that would affect $_GET. And I've checked spelling/ typos so please don't suggest that
  10. hmph. ... I knew that. (/ is the web root in headers and includes... I guess I assumed it would be the same. haha) Anyways, enough blabbering. It worked, obviously. Thanks, and thanks for the quick reply once again. Eventually I'll stop being such a novice.
  11. Thanks guys for the fast replies - How do I do a relative path into another folder at the same level, then? I need this code to be able to work on any subdomain/ domain so that I can reuse it without editing the code, so I can't do a full path. I'm assuming it's a path problem because the access is being denied into the same exact page. Thanks though. Besides, fopen() is how you create files that don't exist, right? Or is the internet lying to me I wouldn't be surprised. haha
  12. I have a subdomain with two folders. For some reason I can't check if a file exists from "directory A" from "directory B," nor can I create a file in "directory A" from "directory B," however I CAN create a file in directory B into directory A. For whatever reason the path doesn't work. $newfile = "/inc/example.php"; if(file_exists($newfile)){ echo "yes <br>".$newfile; }else{ $createfile = fopen($newfile, 'w') or die("can't open file"); fclose($dreatefile); }; It gives me this warning: Warning: fopen(/example.php) [function.fopen]: failed to open stream: Permission denied in /home/MYSITE/public_html/subdomain/folderA/create.php on line 20 can't open file
  13. @ PFMaBiSmAd Aaah! THAT'S WHY I knew I'd done something stupid. I forgot session_start(). I fail at life. Thanks so much! (Though I feel stupid now... lol)
  14. @waynewex I said it was a small script? As in I haven't added all that yet? And all emails, usernames, and ids are unique, but thanks anyways. If you have pertinent comments (such as an answer to the problem that I posted) feel free to contribute them I'd love the help! And the query is fine, as it's being echoed as 1, meaning it found the connections. @MatthewJ Thanks. haha But no, there's not more then one because there's only two fake "accounts" right now, lol. And like I said when it's echoed the mysql_num_rows comes out as 1, not 2 or 0 or 5 or 1000.
  15. I created a very small log in script. As you can see, the post information is identified as $user and $pass. When echoed they both appear as the information submited through the form on index.php. Next is database stuff. When $obtainnumber is echoed, it is echoed as "1." However the if statement (if($obtainnumber==1)...) does not work and I'm always sent to the else statement!? Can someone see any problems in the code that would make the echo work but not the if statement? I've made similar codes (executing certain codes if the mysql_num_rows is a certain number, such as 1 or 0.) in the past that have worked. Thanks in advance. <?php $user=$_POST['username']; $pass=$_POST['password']; mysql_connect("localhost", "example", "example") or die(mysql_error()); mysql_select_db("example") or die(mysql_error()); $obtainlogin=mysql_query("SELECT * FROM networks WHERE username='$user' && password='$pass'"); $obtainnumber=mysql_num_rows($obtainlogin); if($obtainnumber==1){ $obtained=mysql_fetch_array($obtainlogin); $_SESSION['id']=$obtained['id']; $_SESSION['username']=$obtained['username']; header('location:/index.php?success=login'); }else{ header('location:/index.php?problem=login'); }; ?>
×
×
  • 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.