Jump to content

stuartmarsh

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

Everything posted by stuartmarsh

  1. Hmmm I've just renamed the .htaccess to old.htaccess and the problem persists.
  2. I think your right, this may be a .htaccess issue as I've just created another sub-domain and the problem does not occur. So are these rules redirecting regardless? It should only redirect if the domain ends .com or doesn't begin www.
  3. I don't think its cookies. The code in the first post is the only code in the files and register Globals is off. I've tried a few different names and they all result in the same problem.
  4. I've echoed session_id and it remains the same at all times. Only one .htaccess in the root, code below: RewriteEngine on RewriteCond %{HTTP_HOST} ^domain.com$ [OR] RewriteCond %{HTTP_HOST} ^www.domain.com$ [OR] RewriteCond %{HTTP_HOST} ^domain.co.uk$ RewriteRule ^/?$ "http\:\/\/www\.domain\.co\.uk" [R=301,L] #Route HTML pages through index.php (page.html -> index.php?page) RewriteRule ^(.+)\.html$ index.php?file=$1 [NC]
  5. I've added those lines of code to both files, run them, and I still experience the problem.
  6. Sorry didn't mean switching domains, meant url. Both url's are on a dev sub-domain (dev.domain.co.uk/test.php & dev.domain.co.uk/admin/test.php). Code is at the bottom of the first post.
  7. Hi, I'm not switching between domains and phpinfo() shows session.cookie_path set as /.
  8. Hi all, I have two PHP files, one in root and the other in a folder called admin. If I set $_SESSION in a file in the admin folder and then view $_SESSION in any other file within the admin folder, everything is OK. However, if I then go to a file in root $_SESSION is blank, and it is blank if I then go back to a file in admin. This problem only exists on my hosting and doesn't happen on a local dev machine. I've compared the php.ini session settings and there both the same. Any ideas? Files admin/test.php <?php session_start(); if( empty($_SESSION) ) { echo "Session not set<br />"; $_SESSION['test'] = "test"; } echo "<pre>";var_dump($_SESSION);echo "</pre>"; /test.php <?php session_start(); echo "<pre>";var_dump($_SESSION);echo "</pre>";
  9. Still playing around with this. I have modified my regex to the following /(?=select|from|(left|right) (inner|outer) join|where|group by|having|order by)/im Can I make the (left|right) and (inner|outer) optional? So that it matches JOIN but also matches if there is any combination of left/right/inner/outer before it? Thanks
  10. I think I'm going to include each type of join manually. If two joins are on the same line it doesn't work properly. Thanks.
  11. I'm trying to break up a SQL statement so that I can can work on each segment individually. This is the code I have so far. $SQL = "SELECT * FROM Table_1 INNER JOIN Table_2 ON Table_1.ID=Table_2.Table_1_ID JOIN Table_3 ON Table_1.ID=Table_3.Table_1_ID LEFT OUTER JOIN Table_4 ON Table_3.ID=Table_4.Table_3_ID WHERE Field1='BLAH' AND Field2 IN ('1', '2', '3') GROUP BY Field1, Field2 HAVING Field3='CHOO' ORDER BY Field1, Field2 "; $test = preg_split('/(select|from|(.*)join|where|group by|having|order by)/im', $SQL, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); var_dump($test); This is the result: array 0 => string 'SELECT' (length=6) 1 => string ' * ' (length= 2 => string 'FROM' (length=4) 3 => string ' Table_1 ' (length=10) 4 => string ' INNER JOIN' (length=14) 5 => string ' INNER ' (length=10) 6 => string ' Table_2 ON Table_1.ID=Table_2.Table_1_ID ' (length=43) 7 => string ' JOIN' (length= 8 => string ' ' (length=4) 9 => string ' Table_3 ON Table_1.ID=Table_3.Table_1_ID ' (length=43) 10 => string ' LEFT OUTER JOIN' (length=19) 11 => string ' LEFT OUTER ' (length=15) 12 => string ' Table_4 ON Table_3.ID=Table_4.Table_3_ID ' (length=47) 13 => string 'WHERE' (length=5) 14 => string ' Field1='BLAH' AND Field2 IN ('1', '2', '3') ' (length=50) 15 => string 'GROUP BY' (length= 16 => string ' Field1, Field2 ' (length=21) 17 => string 'HAVING' (length=6) 18 => string ' Field3='CHOO' ' (length=20) 19 => string 'ORDER BY' (length= 20 => string ' Field1, Field2 ' (length=16) As you can see it's sorta doing the right thing but I need it to only split before the keyword, instead of before and after as it is doing. It is also producing two results when there is an "Inner Join". Can someone point out what I'm doing wrong? Thanks, Stu
  12. I have some SQL that gets the current week number based on today's date I.e 200940. Based on that I want to get the last n weeks, so ultimately I have a SQL that gives me WeekNo 200940 200939 200938 200937 I could do this with a loop in PHP but I'm trying to do it in the SQL if possible.
  13. Hi All, I don't know if this is simple or not, but I'd like some SQL to return a number of sequential values starting at a number I specify. For example, I want to start at 5 for 5 iterations. The result I would like back would be Numbers 5 6 7 8 9 Thanks.
  14. Bingo! This works exactly the way I need it. Thanks MadTechie.
  15. Using your example I changed the sql to Code: [select] $SQL = "SELECT col1, col2, col3,col4 , IFNULL(blah, 'foo') AS foolah, foo AS [bar1], COUNT(foo) AS 'bar2' FROM table WHERE col1='A';"; and Code: [select] $str = trim($str," `"); to Code: [select] $str = trim($str," `\]['"); . Now it removes the ] and the end ' for array keys 5 & 6 respectively. But I'm still left with a [ on array key 5 and a start apostrophe on array key 6.
  16. Using your example I changed the sql to $SQL = "SELECT col1, col2, col3,col4 , IFNULL(blah, 'foo') AS foolah, foo AS [bar1], COUNT(foo) AS 'bar2' FROM table WHERE col1='A';"; and $str = trim($str," `"); to $str = trim($str," `\]['"); . Now it removes the ] and the end ' for array keys 5 & 6 respectively. But I'm still left with a [ on array key 5 and a start apostrophe on array key 6.
  17. Hi all, Thanks for the replies and code. The code from MadTechie looks good. The code looks good but there is just one more consideration. When using the AS clause I use either ' or [] around the alias name (I.e. col1 AS [foo 1], col2 AS 'foo 2'). Can I use trim to filter out ', [, & ]? I tried adding them to the charlist but it only removes the end apostrophe and "]". Thanks all!
  18. Hi all, I'm looking for a regex to extract fields from a SQL string. SQL: SELECT col1, col2, col3 FROM table WHERE col1='A'; Expected results: Array[0] = "col1" Array[1] = "col2" Array[2] = "col3" Or at the very least a regex to get the string between SELECT and FROM. Then I split it down and extract them programmatically. SQL: SELECT col1, col2, col3 FROM table WHERE col1='A'; Expected results: Array[0] = "col1, col2, col3" Cheers, Stu
  19. I have a main domain on a .co.uk and a parked domain on .com. I have a .htaccess setup that redirects the .com and the domain without the www to my main domain. However, I can still access pages through domain.com/aboutus.html when I want it to redirect it to www.maindomain.co.uk/aboutus.html. RewriteEngine on RewriteCond %{HTTP_HOST} ^Domain.com$ [OR] RewriteCond %{HTTP_HOST} ^www.Domain.com$ [OR] RewriteCond %{HTTP_HOST} ^MainDomain.co.uk$ RewriteRule ^/?$ "http\:\/\/www\.MainDomain\.co\.uk" [R=301,L] #Routes pages through the index.php RewriteRule ^(.+)\.html$ index.php?file=$1 [NC] Can anybody tell me how to modify this so that it redirects page requests to my main domain? Cheers, Stu
  20. I'm messing with using XML to create a menu system and I am using SimpleXML. I'm want to merge several XML files together to produce the final menu XML. The menu XML looks like this: <menu> <item title="Home" link="home.php" /> <item title="Content" link="content.php" /> </menu> I have another XML called items that looks like this: <menu> <item title="Page1" link="page.php?id=1" addTo="Content" /> <item title="Page2" link="page.php?id=2" addTo="Content" /> </menu> I want to loop through the "items" XML and add a new child under the element that has a title that matches 'addTo'. Is there a quick way of doing this without looping through the menu XML for each item? Something like $xmlMenu->item->"title="content"->addChild($name, $value)? The final output should resemble this: <menu> <item title="Home" link="home.php" /> <item title="Content" link="content.php"> <item title="Page1" link="page.php?id=1" /> <item title="Page2" link="page.php?id=2" /> </item> </menu> Thanks.
  21. This regex is based on another that I found that did a similar thing. Can you tell me what I can do to make it do what I want?
  22. I'm trying to replace text between {{PHP}} and {{/PHP}} but all that happens is my I get part of my text back. REGEX: /\{\{PHP\}\}(.*?)\{\{\/PHP\}\}/ SAMPLE:{{PHP}}TEXT{{/PHP}} RESULT: {{PHP}}TEXT EXPECTED RESULT: TEXT Can somebody tell me where I'm going wrong?
  23. Awesome this does exactly what I need! Thanks very much nrg_alpha. Your guru status is well deserved.
  24. Hi, Can anybody tell me if it is possilbe to split a string at spaces except where the space is between " using preg_split? IE: String: Split this "string by spaces" would produce segment1: Split segment2: this segment3: "string by spaces" Thanks.
×
×
  • 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.