Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. No. & represents the character &. It has to be escaped in the HTML source because you can't just have an ampersand. That character has a special meaning in itself. Same with other characters like "greater than" or "lower than" and other characters.
  2. It doesn't change the value, it returns a new value. Few of the functions have what you call a side effect. Edit: I misread your topic, but you still have to do it each time. It doesn't mean that the value will be &, but it has to be like that in the HTML source in order to be valid. The posted value will still be &.
  3. Try to forget the technical implementation. If you demolish a house, does its rooms persist to exist? No. It kind of depends on what you're doing. The object instance is always destroyed when the script execution ends, so in that sense, neither the house nor its rooms should be removed from the database (unless you only want them to persist for the duration of the script's runtime of course). If you are actually deleting the house, the rooms should be deleted as well.
  4. Imagine a database like this: CREATE TABLE `houses` ( `house_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, `price` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`house_id`) ) ENGINE=InnoDB; INSERT INTO `houses` (`house_id`, `name`, `price`) VALUES (1, 'My House', 5000000); CREATE TABLE `rooms` ( `room_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `house_id` int(10) unsigned NOT NULL, `name` varchar(100) NOT NULL, `size` int(10) unsigned NOT NULL, PRIMARY KEY (`room_id`), KEY `house_id` (`house_id`) ) ENGINE=InnoDB; INSERT INTO `rooms` (`room_id`, `house_id`, `name`, `size`) VALUES (1, 1, 'My Kitchen', 20), (2, 1, 'My Bathroom', 5); ALTER TABLE `rooms` ADD CONSTRAINT `rooms_ibfk_1` FOREIGN KEY (`house_id`) REFERENCES `houses` (`house_id`) ON DELETE CASCADE ON UPDATE CASCADE; Each house has a composition of rooms. Without the house it doesn't make sense to talk about its rooms, so when the house ceases to exist, so does its rooms. I hope that makes sense.
  5. So what's the problem with doing that? What does your code look like? How have you laid out your database?
  6. <?php include (TEMPLATEPATH . "/random-layout/single" . rand(1, 3) . ".php"); ?>
  7. Any 1:1 or 1:n relationship will need two tables unless the relationship is self-referential.
  8. I've got one laptop.
  9. It's because they're called PCRE (Perl Compatible Regular Expressions). In Perl you'd do: if ($string =~ m/a-z0-9/i) { print "It's an alphanumeric string!"; } You also use that notation in other places, like in the editor called vi(m).
  10. Except you'll also need to remove the delimiting / characters. nrg chose a hash sign as delimiter. You can use a forward slash as well, but you can't just add that, you'll have to change it. $post = preg_replace('#[^a-z0-9_.-]#i', '', 'd!@#agsd$%^&*');
  11. You can run the query LAST_INSERT_ID() or use PHP's mysql_insert_id
  12. That's why I like using DOM for parsing HTML. You don't have to think about optional quotes, attribute order, etc. It's also much more readable, and it's quick to write. You don't just look at the first regex you made and see exactly what it's doing. The DOM interface is much more descriptive and you should be able to figure out the semantics instantaneously. I think the performance overhead is worth it in the majority of the cases. Yea, but that's not valid HTML. But who knows if the content he's grabbing from is, so good point. Yes it is. Attribute quoting is optional as long as you only use alphanumeric characters, periods, hyphens and colons in the attribute value.
  13. I mean what I said. The database doesn't live in memory, but on the file system. I already said what Sphinx is. It's a search daemon. Do a Google search if you want more information.
  14. mysql_num_rows doesn't take the $link parameter. Only a resource as first parameter.
  15. eval() evaluates PHP code. It's starting "within" PHP, so to speak. So you just exit PHP by starting with ?>. That's why it works.
  16. Take an extra look at this: $query=mysql_query("Select * From user_table where pfno='$pfno'") or die (mysql_error()); $result=mysql_query($query); And now tell me what is wrong.
  17. Uhm... $string would be a variable containing the code, so in your case, $string would contain: <h1>Users</h1> <p> <?php $q = mysql_query("...."); $qa = mysql_fetch_assoc($q); ....more php.... ?> </p> I.e., the stuff from your database.
  18. Have you checked that $eventid contains the correct value?
  19. Isn't that what thebadbad's does?
  20. Looking at the headers you'll see WWW-Authenticate: Negotiate WWW-Authenticate: NTLM So this is not HTTP Basic authentication. NTLM is the NT LAN Manager, so your school is using the Windows domain's authentication framework. On a school I once went to they used that for their intranet as well. I remember that in Internet Explorer you would have to explicitly specify the domain name, so it would be like domain\user instead of just user. You can try to see if that works. Otherwise, try to read up on NTLM authentication to see if you have to go through some weird hoops to get in.
  21. Are you running as root?
  22. You want something which is random, but doesn't change?
  23. Say $countries as an array of all countries and $userCountry is the selected country. <select name="country"> <?php foreach ($countries as $country): ?> <option value="<?php echo $country ?>"<?php if ($country == $userCountry): ?> selected="selected"<?php endif ?>><?php echo $country ?></option> <?php endforeach ?> </select> Or use one block of PHP code and echo statements or whatever you prefer.
  24. The manual is a great place!
  25. http://php.net/manual/en/language.types.string.php
×
×
  • 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.