Jump to content

cags

Staff Alumni
  • Posts

    3,217
  • Joined

  • Last visited

Everything posted by cags

  1. It is important to note they won't always give the same result. If for example you give validation the value of 0, the first statment will calculate isset as TRUE and as such will perform the code inside the if block. The second statement will take the value of validation to be FALSE and therefore the code within the if block will not be performed.
  2. I suggest you take a look at this aritcle. It seems that many of the inbuilt PHP functions such as strlen just do not work with multi-byte characters. I'm not sure if this is what's causing part of your problem, as your code works on my computer, but it's an interesting read none-the-less and may give you some inspiration.
  3. As far as I can tell the problems you are having must revolve around the JavaScript section. <SCRIPT LANGUAGE="JavaScript"> <!-- Hide code from non-js browsers function validate() { formObj = document.CustomerForm; if ((formObj.ContactName.value == "") || (formObj.CompanyName.value == "") || (formObj.YourPosition.value == "") || (formObj.ContactEmail.value == "")) { alert("You have not filled in all required fields."); return false; } else { header("Location: $redirecturl"); return true; } } function formReset() {document.getElementById("CustomerForm").reset()} // end hiding --> </SCRIPT> As this code is ran when you submit the form, if you have filled in the 4 required fields it will attempt to run the line... header("Location: $redirecturl"); To my knowledge that is not valid JavaScript code and that line shouldn't be there at all. Once I removed that, the script seemed to 'move on'.
  4. Certainly, the getimagesize function should suffice for your requirements. <?php $size = getimagesize($path); if($size[0] < 10 || $size[1] < 10) { // it's too small } else { // it's fine } ?>
  5. Hi, my name is Pete or Cags as I tend to be called online and I'm from Leicestershire (UK). I'm 26, I started to teach myself PHP about 4 months ago. I'll probably (try to) be giving more help as opposed to asking questions around here. Just thought I'd say hello.
  6. preg_replace is a Regular Expression function for replacing one string pattern with another, I don't see what this has to do with checking the size of an image?
  7. You should be able to use either... <?php echo $item['fp']['id']; echo $item['fp']['goupid']; // etc, etc.. foreach($item['fp'] as $k=>$sub_item) { echo $k . " = " . $sub_item . "<br/>"; } ?> Note: obviously I just echo'd out the values, the idea was to just show you how to access the elements. You can use these values to insert into the database.
  8. People will debate all day about whether you should solve or ignore Notices, but one thing thats fairly certain, they are not what are stopping your code working. If you copy the code I posted and just the code I posted into the two respective files, it will work (the caveat being that I used a .php extention for the included file, depending on your server settings it might not parse PHP in the .inc file correctly) . If your code is not working there is something else in your script causing the problems. Without seeing the whole script I'd need a magic ball to work out what exactly that might be.
  9. Do you have access to the php.ini? There is a session.cookie_lifetime setting.
  10. What about if you use this? Do you get HIT printing out alot? foreach($users as $user) { $Add_this_user = TRUE; foreach($stream_users as $stream_user) { $todays_date = date("Y-m-d G"); if(($user[1] == $stream_user[4]) && ($stream_user[3] == 'active')) { if(((preg_match('/A/', $user[8])) == 0) || ($user[9] < $todays_date) || ($user[7] == 1) || ($user[5] == 0) || ($user[6] == 0) || ($user[10] == 1)) { $Add_this_user = FALSE; } } $Add_this_user = FALSE; } if($Add_this_user) { echo "HIT"; if($user[1] != NULL) { $add_list[$r][1] = "<parameter id='{emailaddress}'><value>".$user[1]."</value></parameter>"; } if($user[2] != NULL) { $add_list[$r][2] = "<parameter id='{firstname}'><value>".$user[2]."</value></parameter>"; } if($user[3] != NULL) { $add_list[$r][3] = "<parameter id='{lastname}'><value>".$user[3]."</value></parameter>"; } if($user[4] != NULL) { $add_list[$r][4] = "<parameter id='{title}'><value>".$user[4]."</value></parameter>"; } $r++; } }
  11. If you say so, though http:// is included nowhere in your first post. The exit() strictly speaking in your case might not be required, it is however best practice. After sending a Location header, the script does keep running, which is something you don't actually want to happen. If you have no other code below it doesn't espcially matter, but if you have a full script below, you don't want it running.
  12. It's possible that you have short_open_tag set to false in your php.ini. Your redirect wouldn't have completed correctly without the http:// part of the url. This code should work. <?php include('SignUp/questconfig.inc'); if ($redirecturl != "") { header("Location: $redirecturl"); exit(); } else { echo "<br><center>$finishedtext</center><br>"; } ?> <?php # url the form will redirect to after sending email $redirecturl = "http://www.site.com"; # text that will display if you leave above variable blank $finishedtext = "Thank you for your interest, We will be contacting you soon!"; ?>
  13. As the OP pointed out it's coded in such a way that every loop of the inner loop should set it to false. The only explanation I can see is AlexWD's suggestion that $stream_users is empty so the loop isn't running.
  14. That's true but somewhat irrelevant mikesta707. Assuming I understand the OP correctly. Regardless of the code inside the inner foreach loop, when the code exits this loop the value of $Add_this_user would always be false. The OP seems to indicate that the // do something code is still being performed (which doesn't sound right to me).
  15. I have practically the same setup as you. The only difference being I use XP 64bit rather than Vista. I just tried you code, and it worked perfectly on my computer. %E9 is actually é %C9 is É Thats not really relevant though. Sorry I can't be of any help, just wanted to let you know it works for me (on all modern browsers), so it sounds like a configuration issue.
  16. I'm not sure what your asking here?! Does your code look like one of these? <?php $sql = "Some Query"; $result = mysql_query($sql); // this $session['result'] = $result; // or this $session['result'] = mysql_fetch_array($result); ?>
  17. This is the approach I've taken in the past, not sure if it would be considered the best method. But it should certainly work for you in this situation. <?php $result = mysql_query("SELECT * FROM `events` WHERE `bar`='Its All About Us' ORDER BY `date`"); $curr_date = ''; while($row = mysql_fetch_array($result)){ if($row['date'] != $curr_date) { echo '<h3>' . $row['date'] . '</h3>'; $curr_date = $row['date']; } echo '<p>' . $row['event'] . '</p>'; } ?> Note: You will probably need to change that slightly to get your formatting back, it's just an example of the logic.
  18. Just incase anybody else is wondering what herghost was suggesting (took me awhile to spot the difference, maybe I'm just slow), they have basically switched the single and double quotes over on the rows of code that echo out anchor links. <?php $var = "Test"; echo '$var'; // will give an output of $var echo "$var"; // will give an output of Test ?> Also in the OP's code, the src attribute of the first anchor tag didn't have a closing quotation anyway. I should also point out that the href attribute doesn't have quote's around it in either post, which I assume it should have. <?php if ($counter % 3 == 0) { echo '<a href="#"><img src="thumb.php?image="'. $currentImage .'" alt='' /></a><br/>'; } else { echo '<a href="#"><img src="thumb.php?image="'. $currentImage .'" alt='' /></a>'; } ?> Note: I changed the order back, for no other purpose than thats my prefered method, the way herghost suggested should have been fine. If this doesn't work, I suggest you look at the outputted HTML and check if the value you have in the src attribute looks correct and is in the form of (what I'm presuming was the correct format) of "thumb.php?image=beach.jpg".
  19. It would have been helpfull if you had included what type of Parse error your getting, but nevermind. Directly below the second section of code you posted, there is a curly bracket placed in a position that is not valid, thats what is causing your error. <?php if ($userfile_Size == 0) { errors[] = 'Please upload your DXDIAG txt file.'; } { if (count($errors) > 0) { ?> Looking at the code you posted it's difficult to tell if it's meant to be a closing bracket rather than an opening bracket, or if it's not supposed to be there at all, hopefully you will know that though.
  20. It seems to specify that $to doesn't have a value (or at least a valid value). How about you show us what values you are passing in as parameters to mail()?
  21. Simply do a find and replace. Choose something that the user is unlikely to want to use in their message. So for example you could tell the user to put [iMAGE] wherever they want the image to appear. Then before you send the e-mail you $message = str_replace('[iMAGE]', $link, $message);
  22. So running this line of code... $htmlval=file_get_contents('http://google.com'); Results in an error for you?
  23. In your $sql variable, you have single quotes before and after the first and last VALUES variables, but only after the second... Try... <?php $sql="INSERT INTO events (bar, date, event) VALUES ('$_POST[barname]','$_POST[date]','$_POST[event]')"; ?>
  24. In your php.ini (in your case probably located at c:\wamp\php\php.ini, but I'm not sure as I use xampp not wamp) file, there will be a line of code that says... sql.safe_mode = On You need to change it to... sql.safe_mode = Off
  25. unlink certainly should be the correct way to delete a file. The fact that you use fclose, should mean that the file won't be locked. To my knowledge output_file is not a built in PHP function, so I rather suspect whatever that function does is causing what you are percieving as the problem.
×
×
  • 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.