newbtophp
-
Posts
631 -
Joined
-
Last visited
Posts posted by newbtophp
-
-
Yes I am. And I see now how confusing my answer was to you. IF I had bothered to check first I would have said that the \ in the 4th argument would ensure that your cookies would be in the correct place regardless of what domain name was in $site. The cookies will be in the domain root because of the \ although the absolute path of that location will be different depending upon the current $site/domain value.
Appreciate you clarifying, however if $site was set to domain.com, would cookies be readable on any other variation such as www.domain.com or somethingelse.domain.com or www.somethingelse.domain.com (which is what I don't want)?
-
Why don't you read the manual re: cookies? You do read the manual when you have questions first, don't you?
I have as mentioned in my initial post, my follow up question was to clarify your response, are you referring to the fourth parem of setcookie()?
-
I think that a simple \ should work. It will represent the root folder of whatever the domain is pointing to, no?
Hmm...If I understand you correctly - do you mean changing $site to '/' ? - did not know you could do that.
-
I have a script where $site (location of where it's hosted) will either be in the format of a subdomain e.g. 'something.domain.com' or a domain 'domain.com', and the cookies are handled like the following:
ini_set('session.cookie_domain', $site); //for sessions
setcookie($name, $value, $expiry, '/', $site, false, true); //for othersMy question is the script's canonical url is non-www and I don't want other subdomains for various reasons (including security) being able to access/read the cookies (e.g. 'www.something.domain.com' or 'www.domain.com' or 'somethingelse.domain.com' or 'www.somethingelse.domain.com'), so would you say the above will work okay (providing $site does not proceed with www. or .)?
I have searched around (also referred to php.net) and believe the above will be okay from my understanding - but wanted reassurance as I had read many conflicting/confusing information!
Edit: If the above won't work - I thought about maybe setting $site to false (the .htaccess code would enforce access only via non-www)?
-
Heya!
I've coded a small php template parser, so templates can be easily parsed, and the variables within the templates are like {variable_name} e.g.
<title>{title}</title>
Can you suggest me possible if/else statement syntax?
I've thought of doing something like:
{if {logged_in}: TRUE}
Your logged in...
{else}
Your not...
{/if}
and...
{if {logged_in}: TRUE}
Your logged in...
{/if}
The above demonstrates basic if/else template syntax (it checks if the variable logged_in == true), but since I'm more of a coder then designer, was wondering if I can have your input (so designers can easily understand the syntax without knowledge of server-side coding).
Cheers!
-
i figured out how to convert a TimeStamp to real time
by doing this
$time = $_SERVER['REQUEST_TIME'];//Onix Time Format print date('Y-m-d H:i:s', $time); // 2010-09-26 04:25:49
But i dont know how to convert 2010-09-26 04:25:49 Back to a Time Stamp
Any ideas?
nevermind .. i figured how to do it
seems that the mktime function dos it
strtotime does that
-
I currently have the query below:
SELECT table1.id, table1.review, table1.time, table2.author, table2.title FROM table1, table2 WHERE table1.id = table2.id AND table1.reviewer = '{$username}' ORDER BY table1.id
Im using the above quite alot around my sites code...and sometimes adding the table prefixes etc. before the column names can make the query very long and take up quite alot of lines.
Is their a way to make the above query more simple/easier, as its quite basic as I just followed the basic tizag examples.
Hope someone can help!
-
Hi
First problem is that you need to join the tables on a field. What you have is a cross join, and will bring back every combination of the rows from the 2 tables.
As to checking an aggregate value, use a GROUP BY to group the records you want to count and use a HAVING clause to check the value.
All the best
Keith
$pm_query = "SELECT table2.id FROM table1, table2 WHERE table2.id = table1.id AND table1.author = '{$username}'"; $pm_reply_count = mysql_num_rows(mysql_query($pm_query)); //final query (which shall be used within a while loop) $pm_id_query = "SELECT id FROM table1 WHERE (id = '{$id}' AND author = '{$username}' OR pm_author = '{$username}' AND {$pm_reply_count} > 0) AND deleted = 0";
I've come up with the above? but its kinda hackish? - their must be a better way I'm just unsure on how to
-
SELECT table1.title, table1.status FROM table1, table2 WHERE table1.author = '{$username}' AND COUNT(table2.id) > 0 AND table2.deleted = 0
But I get an error, but when I remove the ' AND COUNT(table2.id) > 0' the error goes; theirfore whats the correct way to do this?
-
Thanks mjdamato I used your first example
-
$array = array(); for ($i = 97; $i < 123; $i++) { $array[] = chr($i); } for ($i = 65; $i < 91; $i++) { $array[] = chr($i); }
Its quite time consuming looping, perhaps combine in 1 or?
-
If i use mysql_real_escape_string() whilst inserting data...and that data contained 'common sql injection chars' - im guessing it would escape/backslash them?
So say if I now wanted to select/extract that data from the DB, would the data contain the slashes or would the slashes be automatically removed/stripped?
-
Im working on my own (basic) forum sofware how would I determine if the user has read or unread the topic? (like SMF has a specific icon when viewing the forum/topic list which represents theirs unread topics within this forum).
:-\
-
Sorry for bringing up this thread, but how would i set N/A if any of the selected rows are empty? (defining each an every row would be tedious?)
Like
SELECT something, another, hey FROM table, IF ANY ROWS (in this case something, another, hey) IS EMPTY THEN DISPLAY N/A
-
cheers premiso!
-
How can I check if a function has returned false.. I know theirs the following way:
if (!checkdate($month, $day, $year)) { //the function has returned false }
But is their another way (beside using the ! operator) perhaps === FALSE (not sure if that'd work so asking)?
-
I don't see anything wrong with your current method. That is generally how all star voting systems work. People vote 1-5 and you display the average of those votes. So what if the first vote is 5 and that boosts it to 5 automatically? That's why you also display the number of votes so people don't get the wrong idea.
Well I know but say if theirs 1 vote of 5, the score will = 5 (however thats 1 voters opinion which can effect the importance or quality of the content), and if for example I display a 'Top X' based upon their score, they can jump to the list.
I googled around and found the following:
http://www.thebroth.com/blog/118/bayesian-rating
But seems abit too mathematical for me to integrate, so was hoping someone could help me.
EDIT: added a better example
-
Someone suggest using bayesian algorithm, but I'm not sure how to implant that using my current db structure (without the score going over 5)
Any help or any better way you can think of (to improve upon my current method)?
-
cheeers wildteen
-
I want to display 50 results, theirfore I'm using a while loop to do so, the issue is, if $row consists of results lower then 50 (it will display them) and not display 50..so I'm trying to figure out a way so even if $row doesn't cosist of 50 i'll display what it has aswell as continue the $i (and for the rest display NO CONTENT).
I've come up with the following on the spot (not sure if it even would work) - but was wanting a better solution.
$i = 0; $results = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { $i++; echo $i .' CONTENT '.$row['name'].'<br />'; } if ($result < 50) { for($i <= 50 - $result; $i++) { echo $i .' NO CONTENT<br />'; } }
-
Anyone can help? I tried using [^\-]* but doesn't seem to make any effect?
-
Cheers that worked alhough i think theirs a slight error did you mean <= instead of >= within the for loop?
-
I'm trying to do a for loop to provide 2 numbers $x and $i, +199 every time?.
E.g.
First loop:
$i = 200;
$x = 399;
Second loop:
$i = 400;
$x = 599;
Third loop:
$i = 600;
$x = 799;
and so on until $x = 1400; (then stop).
-
~^(??<!\-)[a-z0-9\-]{2,}(?!\-)|(?<!\-)[a-z0-9\-]+(?!\-)\.(?<!\-)[a-z0-9\-]{2,}(?!\-))$~D
I have the above expression, which will match the specified characters (with the specified length) and optionally a fullstop followed by more specified characters (with the specified length).
Im trying to make it so it matches only if its not proceeded by a - and not followed by a - .
So example the following will match:
hey.phpfreaks
hey
yo-u.me
However the following will not match:
-hey
hey-
-hey-
you.-he
I've tried using (?<!\-) (not proceeded by -) and (?!\-) (not followed by -) but that doesn't seem to work?
Setting the domain correctly for cookies
in PHP Coding Help
Posted · Edited by newbtophp
I guess cookies being readable on the www. version is really a no issue, the main concern lies with cookies being readable on subdomains - which I don't want (due to security).