Jump to content

fry2010

Members
  • Posts

    326
  • Joined

  • Last visited

Everything posted by fry2010

  1. I think it has something to do with having two conditions that can be treated the same. Because when i place two conditions exactly the same then it gives server error. example: RewriteCond %{REQUEST_URI} ^/www.mysite.com/(.*)(/*)$ RewriteRule ^(.*)$ /www.mysite.com/index.php?aff=$1 [QSA] RewriteCond %{REQUEST_URI} ^/www.mysite.com/(.*)(/*)$ RewriteRule ^(.*)$ /www.mysite.com/index.php?loadPage=$1 [QSA]
  2. tried that, but still gives server error. Strange because when I place them the other way around there is no server error.
  3. actually I am having a problem trying to get that to work. RewriteCond %{REQUEST_URI} ^/(.*)/page([0-9]*)$ RewriteRule ^(.*)$ /www.mysite.com/index.php?special=$1 [QSA] RewriteCond %{REQUEST_URI} ^/www.mysite.com/(.*)$ RewriteRule ^(.*)$ /www.mysite.com/index.php?loadPage=$1 [L,QSA] I get an internal server error. Exceeds 10 internal redirects in error log. I have tried them the other way around but that will mean the second condition will never be matched because the first allows for all to be matched. So they need to go this way around. (Which I assume is why you said to use the specific one first...)
  4. cheers gizmola, suppose that is the best way to go.
  5. thanks, thats good to know, but not what I needed it to do. I probably havnt explained very well. Basically I want the first condition to rewrite to the GET variable '$1', and then IF the second condition is also met, then provide that as the second GET variable '$2'. If it does not find the second condition then still perform the rewrite and pass the first variable.
  6. I wish to achieve the following: Redirect www.mysite.com/dir1/dir2 to www.mysite.com?page=$1 At the same time see if there is a specific directory called 'specialpage' and then redirect to www.mysite.com?page=$1&special=$2 I can get the first rewrite to work, but when I try to see if special page is there and pass as a second parameter it stops working if that special parameter does not exist. I know the reason why it does not work, but I dont know what the solution is. Here is what I have so far: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} ^/www.mysite.com/(.*)$ RewriteCond %{REQUEST_URI} ^/(.*)/page([0-9]*)$ ##This is the special page RewriteRule ^(.*)$ /www.mysite.com/index.php?loadPage=$1&special=$2 [L,QSA] The reason it wont work is because when it gets to the second rewrite condition, if it does not match that condition then it will not perform the rewrite rule. I need it to work so that if it does not match the second condition then it will still perform the rewrite rule but leave out the second GET variable. Hope this makes sense.
  7. thanks, I think I will invest in a book. Served me well before when I got one on php and css.
  8. great, thanks for your help. I really dont understand how you can solve this problem so easy, where do you learn to do this kind of thing?
  9. My in-experience in using join statements has come-a-cropper for me, and Im not even sure if that is what is required here. Here is the situation: I have two tables. Table two has a column with a foreign key to table one. I want to select certain column data from table one, but at the same time count(*) how many rows in table two are linked to table one. I know this can be done easy using two statments seperatly, but I imagine there is a solution using just one query. Here are the two table examples: create table table_one ( id int unsigned not null AUTO_INCREMENT, name char(60) not null DEFAULT '', status tinyint(1) unsigned not null DEFAULT 0, PRIMARY KEY (id) ); create table table_two ( id int unsigned not null AUTO_INCREMENT, table_one_id int unsigned not null, PRIMARY KEY (id), FOREIGN KEY table_one_id REFERENCES table_one(id) ON DELETE CASCADE ); Here are the two queries I wish to combine: $sql1 = "SELECT id, name FROM table_one"; $stmt = $conn->query($sql1); // Cycle through result while($fetch = $stmt->fetchObject()) { $table_one_id = $fetch->id; $name = $fetch->name; $sql2 = "SELECT COUNT(*) FROM table_two, table_one WHERE table_two.table_one_id = table_one.id"; } This would give a result like: Table One Id Table One Name Table Two Row Counts Linked 1 'this is first record in table one' 6 2 'this is second record in table one' 9 3 'this is third record in table one' 1 4 'this is fourth record in table one' 0
  10. hmm.. Ok thanks.
  11. thanks for checking it out, I am using version 9. I didnt quite mean the drop down menu itself, but rather that it creates a massive white gap between the header and the page content. Unless you do not see a big white gap there?
  12. I have just completed some updates to my site and have applied a drop down menu list using pure CSS. In I.E. it appears that it is forcing the main page down, and creates a gap that is the same distance that the biggest drop down list goes to. Check it out here: http://www.forextradingsignalservice.com Here is the CSS for the list link: #top-nav { bottom: 0px; padding-bottom: 12px; margin: 17px 0 40px 0; list-style-type: none; display: block; font-variant: small-caps; font-size: 85%; float: left; width: 100%; position:relative; z-index:5; } #top-nav li { float: left; position: relative; } /*--- #top-nav a { display:block; padding:5px; color: #ffffff; background: #000000; text-decoration: none; } #top-nav a:hover { color: #ffffff; background:#6b0c36; text-decoration: underline; } ---*/ /*--- DROPDOWN ---*/ #top-nav ul { background: #ffffff; background: rgba(255,255,255,0); /* TRY TO MAKE INVISIBLE - KEEP THIS */ list-style:none; position: absolute; left: -9999px; /* THIS WILL HIDE THE DROP DOWN LIST WHEN NOT USED - KEEP THIS */ } #top-nav ul li { padding-top: 1px; float: none; } #top-nav ul a { white-space: nowrap; } #top-nav li:hover ul { left: 0; top: 32px; background-color: #242424; padding-bottom: 4px; } #top-nav li:hover ul a { /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */ text-decoration: none; } It works fine in firefox and chrome.
  13. sorry, managed to sort the problem out. I had to make the Conditions appear before the other conditions and also remove the 'www.bargainadds.co.uk' part before directories.
  14. I have had this working on my local computer: RewriteCond %{REQUEST_URI} ^/www.bargainadds.co.uk/local-adverts/(.*)$ RewriteCond %{REQUEST_URI} !^/www.bargainadds.co.uk/local-adverts/images/(.*)$ RewriteCond %{REQUEST_URI} !^/www.bargainadds.co.uk/local-adverts/discount-slip(.*)$ RewriteCond %{REQUEST_URI} !^/www.bargainadds.co.uk/local-adverts/search(.*)$ RewriteRule ^(.*)$ /www.bargainadds.co.uk/adverts.php?q=$1 [L,QSA] But it does not work on live. I have also tried changing the %{REQUEST_URI} part etc..
  15. Ok, I will try to explain this as easy as I can. I want to navigate to 'www.bargainadds.co.uk/local-adverts/general'. Yet I want this to instead redirect to 'www.bargainadds.co.uk/adverts' and give the 'general' part as a GET variable. So basically I am looking to change it to 'www.bargainadds.co.uk/adverts.php?$i=general' The 'general' part may change, because it is a variable. It is just displayed as folders even though I want it to convert to the /adverts.php?i=... part. The problem is I already have some code that redirects pages without the file to the index.php file in the folder if one exists, here is the .htaccess file: Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] RewriteCond %{HTTP_HOST} ^bargainadds.co.uk RewriteCond %{HTTP_HOST} !^bargainadds.co.uk/local-adverts/(.*)$ RewriteRule (.*) http://www.bargainadds.co.uk/$1 [R=301] As you can see I have attempted to stop this from working on the 'bargainadds.co.uk/local-adverts/(.*)$' part but it does nothing. It still gets directed to the index, when it should be saying page not found.
  16. I wondered if it is possible to perform a statement that does a select insert with extra parameters included. Eg: Combine these two queries: INSERT INTO `table1` SELECT `val1`, `val2` FROM `table2`; INSERT INTO `table1` VALUES (`val3`, `val4`);
  17. K thanks. Looks like my problems sorted for now.
  18. ok. I have another question: I have found somewhere else that says another optimization with a query is to use LIMIT 1, but if you are selecting from a primary key, would making it LIMIT 1 even make a difference since only 1 row is returned anyway? eg: "SELECT * FROM table WHERE primrykey = 'example' LIMIT 1"; as opposed to: "SELECT * FROM table WHERE primrykey = 'example'";
  19. great, thanks again fenway. I just used varchar in that to test the explain.
  20. Could this be to do with the fact I specified NOT NULL values, and since the query I enter does not match any record, it therefore cannot return any information about the query? Or something along those lines?
  21. I forgot to say that it is mysql version 5.1
  22. I have several tables, all with a primary key set. But I have just performed an explain on them, and it appears that the primary key is not being used, even though the field is being used in a where clause. I also notice that when I change the tables to include a compound key that it then uses the primary key. Here is one of the problematic tables: create table authors ( username varchar(22) not null PRIMARY KEY, email char(60) not null, password char(133) not null, website char(120) not null default '-', account_type tinyint(1) not null default '0', profile char(150) not null default '-' ); When using: EXPLAIN SELECT * FROM authors WHERE username = 'username' I get this result: possible_keys: NULL; key: NULL; ref: NULL; rows: NULL; extra: Impossible WHERE noticed after reading const tables; This occurs on several tables. But when I change the table to this: create table authors ( username varchar(22) not null, email char(60) not null, password char(133) not null, website char(120) not null default '-', account_type tinyint(1) not null default '0', profile char(150) not null default '-', PRIMARY KEY (username, email) ); I get this result from the explain: possible_keys: PRIMARY; key: PRIMARY; ref: const; rows: 1; extra: Using where, Using index; Am I missing something?
  23. Brilliant, thanks for that. I suppose I am going a bit OTT thinking Im going to have thousands of people on my little crappy site.
  24. Thats why I asked. I would like facts. But if you have 100,000 records and you have to search those records is it really not going to impede performance? Sorry fenway, im not understanding this... Are you saying that basically dont create duplicate data, unless it is an optimization? Where could I actually learn correct ways of database structure? It seems to be allusive to me.
  25. This is more a general question: I have searched around a lot and found that there seems to be the arguement that if you have two or more tables with the same data , that the database scheme is not designed well, since there is redundant data. But in my view there are some situations where it is better to catogorise the same data into seperate tables since it can reduce the time to run a select query, which I find select queries to be run more often than others. Could an expert here explain errors in my thinking here or better inform me, since I dont trust a lot of the other places I find information from. If I give an example: Say a new user registers. I put their data into a table called 'await_validation'. Then once they validate their account the information gets removed from that table, and placed into a different table called 'active_users'. To me this has several benifits over using a field in the 'active_users' table called 'validated'. Basically I think it gives the overall benifit of: Running any statement with a WHERE clause will run more efficiently, since there are less rows AND one less field to process
×
×
  • 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.