Jump to content

doni49

Members
  • Posts

    515
  • Joined

  • Last visited

Everything posted by doni49

  1. Sorry--I just re-read the example a little more closely. // Using single quotes will print the variable name, not the value <--I missed this part echo 'foo is $foo'; // foo is $foo // You can use variables inside of an echo statement $foo = "foobar"; $bar = "barbaz"; echo "foo is $foo"; // foo is foobar
  2. Actually, you DON'T need to concatenate the vars separately (although I personally prefer to because I find it easier to see where my vars are). The following is an example copy/pasted from www.php.net/echo. echo "foo is $foo"; // foo is foobar
  3. 1) try loading the page in your web browser and then see exactly what kind of HTML code is sent to the browser. Copy paste that here. 2) you can make your code a little easier to read by using single quotes for your echo statements if you need to have double quotes in the echo'd portion. This: echo"<td width=\"13%\" height=\"12\" bgcolor=\"$colour1\"> $event_name1</td> <td width=\"13%\" height=\"12\" bgcolor=\"$colour2\">$event_name2</td> <td width=\"13%\" height=\"12\" bgcolor=\"$colour3\">$event_name3</td>"; would become: echo'<td width="13%" height="12" bgcolor="$colour1"> $event_name1</td> <td width="13%" height="12" bgcolor="$colour2">$event_name2</td> <td width="13%" height="12" bgcolor="$colour3">$event_name3</td>';
  4. Uh--talk about contradictions. Don't see a use for preg_match, but the example provided (using preg_match) works. I dun't get that one. ??? Glad to see you got what you needed though.
  5. Sounds like good advice to me. I don't know how many times, the answer has just dawned on me while I was trying to figure out how to explain my question.
  6. Maybe if you give us a bigger sample of your data, we might be better able to help. But right now, it looks like you want to grab everything before a colon and disregard from the colon on. In your first post above, it looked like you had "Science (New York, N.Y.)" and you wanted Science--in fact, that's what you said. Then you're talking about an sed script--WHAT is an sed script?
  7. I'll repeat: www.php.net/preg
  8. I think that depends on the web browser. I doubt if there's anything you can do from the server.
  9. Actually--that's not naming the label. It says label FOR first. When using a label, you need to tell what field it's a label for. This HAS to be the same as the field name.
  10. I'm assuming you are supposed to create the file using a PHP script. Have a look at file_put_contents() and concatenating strings. www.php.net/file_put_contents http://us2.php.net/manual/en/language.operators.string.php Beyond that, you won't learn anything if we do your homework for you. If you have any specific questions as to how these work or what something means, just ask.
  11. have a look at regular expressions. http://us.php.net/preg_matchall
  12. www.php.net/preg
  13. I believe that the TRUE is telling PHP that it can use the INCLUDE PATH (search path) to find the file. But since you're spec'ing the absolute path, you shouldn't need that. That being said, if it's working--what's the trouble?
  14. Try is for exception handling--for example if there's a server problem don't expose your mySQL code to the browser. Here's the code I use to validate my contact form--this portion checks to make sure the Name field is filled in. if (eregi ("^[[:alpha:].' -]{2,50}$", stripslashes(trim($_POST['first_name'])))) { $fn = escape_data($_POST['first_name']); } else { $fn = FALSE; $validForm = false; echo '<p><font color="red" size="+1">Please enter your first name.</font></p>'; }
  15. I'm glad you got it working. But I've NEVER used $HTTP_GET_VARS before. $_GET['diff']; should have done the trick.
  16. Sounds to me like AJAX would be better suited for that but YES I think you COULD do it with PHP.
  17. maybe PHP can't find the file that contains the function? Is the include file in the same folder? P.S. Just to make sure the file really is being included, try adding an echo statement to the included file: echo "This Page DID load"; If you see that string, then it loaded. If you don't then you know it's a problem with being able to find the file.
  18. I'll give you a quick little tutorial to try and help. In the following code, we create a select item (aka drop down list). <select name=birthdate> <option value="1">1</option> <option value="2">2</option> ....... I'm sure you can see where this going </select> The field name is birthdate. In the script that processes your form, you retrieve the field's value using the following: $birthdate = $_POST['birthdate'] The variable will contain the "VALUE" specified in the value parameter of the option. So if the user chooses 2, then the variable will be set to 2. What is placed between the opening and closing of the option is what gets displayed in the list. Now consider the birthmonth list: <select name=birthmonth> <option value=1>Jan</option> This will display Jan--but choosing this will set the variable to 1. <option value=2>Feb</option> This will display Feb--but choosing this will set the variable to 2. ..... Again, I'm sure you can see where this is going. </select> So in the script that process your form, if you create an array of months: $months= array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); Then if the user chose Jan from the list, the following code would cause 1-Jan to be echo'd to the browser: $birthmonth = $_POST['birthmonth']; echo $birthmonth . " - " . $months[$birthmonth]; Once you have that info, you can do anything you want with it.
  19. I eventually got that from his last response but thanks anyway. That kind of makes sense to me but I'm defining a user class and one the class's methods will be to turn a specific right on or off. It accepts a second argument (default is TRUE)--if this argument is TRUE then it turns the right on, if this argument is FALSE, it turns the right off. There is another method that just finds out whether a right is on or off. Thanks for all the assistance guys! I'm going to mark this solved as all my questions have been answered.
  20. 1) what I just gave you uses the same structure--just creates the HTML code with less coding. 2) even if you don't want to use that code to build the form, use the array to retrieve the value (for the months, years and countries--not needed with the date). Using the following, if the user selects 4, $birthdate will be 4. $birthdate = $_POST['birthdate'];
  21. Arrays. In fact, I'd use an array to build the list in the first place: $birthMonths=array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); echo '<select name="birthMonth">'; for($i=0;$i<count(birthMonths);$i++){ echo '<option value="' .$i . '">' . $birthMonths[$i] . '</option>'; } echo '</select name>'; Then to get the value (when the script runs): $birthMonth = $birthMonths[$_POST['birthMonth']]
  22. Plus--I can see the potential for a real problem: What would happen if the READ and NOT_READ bits are both set?
  23. I thought maybe I should further explain point number 1 from above. By default, PHP uses integers for the array keys. But you can use strings if you want--it can be very useful. These all have the same effect--they will all produce a 1d array with integer based keys numbered from 0 to 1: $ar1[]="test"; $ar1[]="test again"; $ar2[0]="test"; $ar2[1]="test again"; $ar3 = array("test", "test again"); While the following will create string based key names: $ar4['First'] = 'Test'; $ar4['Second']='Test again'; $ar5=array('First'=>'Test', 'Second'=>'Test again'); Now the following is an example of a 2d array: $ar6[0][0]="Test"; $ar6[0][1]="Testing"; $ar6[1][0]="keep going"; $ar6[1][1]="still going";
  24. Thanks but that still has me puzzled. If it WAS on and I turned it off, wouldn't that still be the same? If not, I might need to re-think how I'm doing things. If I look at the current setting and it's now off, I wouldn't allow the user to read.
×
×
  • 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.