Jump to content

stuartmarsh

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

stuartmarsh's Achievements

Member

Member (2/5)

0

Reputation

  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.
×
×
  • 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.