Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Ok, the process will be something like: <?php $attend = $_POST['attend']; $meeting_id = '';//not sure how you're going to get this so ive left it blank; foreach($attend as $key => $value){ mysql_query("INSERT INTO `attendance_table` (`meeting_id`,`user_id`,`attendance`) VALUES('$meetind_id','$key','$value')")or die(mysql_error()); } ?> You will, of course, also need to validate the data from the form to make sure the data it what you expect and not the working of a malicious user.
  2. And are you sure you've remembered to open php (perhaps you've used a short opening tag, and short_open_tags is off?) I hope im not sounding patronizing, i just expect its something silly.
  3. Are you sure your host supports php? Did you remember to save the file with the extension .php? Try saving this a file with this text: <?php phpinfo(); ?> As phpinfo.php and opening it. What do you see?
  4. I think i'd go for a preg_match and a str_replace: <?php $str = 'google.com/search?q=web+site+designs&hl=en&rls=GGLR,GGLR:2005-41,GGLR:en&start=90&sa=N'; $search_term= preg_match('|\?q=(.*?)\&|',$str,$matches); $search_term = str_replace('+',' ',$matches[1]); echo $search_term; ?>
  5. Whenever you're looking to debug something with a query, you should do something like the following: mysql_query($query) or die(mysql_error().'<br />Query:'.$query); If there is still no error found, then it's always worth echoing the contents of the query to see what values are in the variables: mysql_query($query) or die(mysql_error().'<br />Query:'.$query); echo '<br />Query:'.$queryl
  6. You can make the data created from forms be arrays. I would suggest you use the user_id as the key. So, try these modifications: <?php while ($row = mysql_fetch_assoc($result)) {//mysql_fetch_assoc is identical to mysql_fetch_array(resultresource, MYSQL_ASSOC but with less typing $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color. echo '<tr bgcolor="' . $bg . '"> <td align="left">' . $row['name'] . '</td> <td align="left">Present <input type ="radio" name="attend['.$row['user_id'].']" value="Present" /> Excused <input type ="radio" name="attend['.$row['user_id'].']" value="Excused" /> Unexcused <input type ="radio" name="attend['.$row['user_id'].']" value="Unexcused" /></td> </tr> '; } ?> You will then have an array within the $_POST array called $attend. It will contain keys which are the user_id and the value with either be present, excused, or unexcused dependant on the radio button selected. You can then loop through $attend array, and do whatever you wish with the values. You will be able to work out which user it relates to by using the keys of the array, and searching your database by user_id.
  7. I would guess that the problem is that the content of yahoo's pages depends significantly on the information it gathers from the user. For instance, i would expect that yahoo can be accessed from a mobile phone, but it would look very differant. Yahoo is probably getting information including browser, OS etc to configure the page for optimal display. I dont think that using fgets will be giving yahoo any of this information, so i would expect you get the cut down version - perhaps something similar to what would be displayed on a mobile phone. This also makes sense as to why it works when you try it with the locally saved copy. The HTML, CSS and javascript has all already been created in your saved page. I wonder if you would achieve better results using cURL - as you can pass many of the things that it might want ( i seem to remember you can send along a user agent for instance) Try looking into the uses of curl in php.
  8. Firstly, no - there are no performance issues with using includes(to the best of my knowledge) since php processes an include as if the code were there in the file. Second, a function is a quite differant thing to an include - however, often people put functions which will be used throughout their site in one file, which they then include where it is needed.
  9. Im not convinced there is anyway to do this in PHP. The only idea i can come up with is to modify your login in .net to also call a php script. Im not sure if thats possible, having never used .net at all. I wonder if a php script could be called which would start a session. You could then check for the existance of the session in the php script in the wiki page.
  10. If anything is done on many pages, then it is generally better to have them as includes. That way, they can be easily modified if any requirements change. The only thing is you should make sure they are necessary to the file when you include them - otherwise you will be slowing your site down for nothing.
  11. Well, as far as i'm aware, a key cant be duplicated in an array - if thats part of the outcome that you wanted(im not 100% sure ) then it's not going to work.
  12. You could also try flushing the content to the browser at certain points throughout the script?
  13. Probably just as easy for you to read it off of the php.net website: http://uk.php.net/readdir
  14. Not if the time limit wasn't at the default of 30 seconds - and not if the time limit has been changed.
  15. Looks alright to me. Have you tried it? Dont forget that scandir() is a php 5 function. If you are running a version prior to that, you'll need to use opendir() and readdir().
  16. When you cut down the file, how much do you cut it down by? Unless your server/hosting is very good, it could simply be that it it taking far longer to execute the script.
  17. You could always advertise in the freelancing section of this forum. There are also a few sites which specialise it people advertising for programmers. The names of them escape me at the moment, but im sure a google search will help you find them.
  18. Looks to me like its just your dots(.) in the query. Try: <?php $sql = "SELECT * FROM mytable WHERE name LIKE '%$name%' OR serial LIKE '$serial' OR style LIKE '$style' ORDER BY mytable_id DESC"; ?> And just as a by the by, try and post code inside [ code][ /code] tags with full php opening tags so we get syntax highlighting - it makes it so much easier to read
  19. Ok, if you modify this line: mysql_query($sql) or die(mysql_error()); to: mysql_query($sql) or die(mysql_error().'<br />SQL:'.$sql); That way you can see what values are being passed into the query.
  20. Right, i would suggest that you name each of your form items as arrays: <input type="text" name="firstname[]" /> <input type="text" name="surname[]" /> You will then have arrays of the following: firstname, surname, roll number and marks. Use the function asort() to sort the surname array whilst maintaining the keys. You can then loop through the array and pull the data from the other arrays with the corresponding keys. Hope that makes some sense
  21. Do you think we could see some of the code you have already? Even seeing the form might help us understand what you're trying to do a bit better.
  22. Well you might want to stop suppressing the errors on your mail function. Try removing the @ symbol from this line: $ok=@mail($to, $subject, $message, $headers); And see if php gives you a usefull error message.
  23. How is your text file laid out? Is it simply an email or each line or is there other information? And what did you mean by you couldn't run the script? Did you get any errors?
  24. In theory, no. But it will depend on your host. Some free hosts put some restriction on the use of the mail() function to prevent spam - i've seen some which only allow you to use it if you're paying to use their email too etc. Some hosts dont support the function at all.
×
×
  • 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.