
king arthur
Members-
Posts
335 -
Joined
-
Last visited
Never
Everything posted by king arthur
-
It doesn't matter how many spaces there are between the opening "<?php" and the call to session_start(). What matters is that there are no spaces (or anything else) at the start of the script before the opening "<?php" tag. What is the error you are getting, and what output are you expecting from this script?
-
Ok so just add [code] $path = $ref_array["path"]; $the_bit_you_want = $domain . $path; [/code] Lookup parse_url function right here:[url=http://www.phpfreaks.com/phpmanual/page/function.parse-url.html]http://www.phpfreaks.com/phpmanual/page/function.parse-url.html[/url]
-
Something like this: [code] $referrer = $_SERVER['HTTP_REFERER']; $ref_array = parse_url($referrer); $domain = $ref_array["host"]; [/code]
-
Noobie Stuff: Very Basics Explained Easily
king arthur replied to Pudgemeister's topic in PHP Coding Help
if( $x != $y) This is basic programming, not just basic PHP but basic C and Javascript too. If you are just starting out learning PHP this forum should not be your first port of call. I recommend getting hold of a book like PHP and MySQL for Dynamic Web Sites by Larry Ullman, or if you're feeling a bit more confident, PHP and MySQL Web Development by Welling and Thomson. I have these beside me always, especially the latter - books like these are your bible when getting started. -
[quote author=RockingGroudon link=topic=101819.msg407151#msg407151 date=1154429629] Me agree but do this too dont use . to join again, cause u can just use time() in side "" [code] $statement = "UPDATE sessions SET expiry = $expiry, value = '$value' WHERE sesskey = '$key' AND expiry > time()"; [/code] [/quote] No you can't - that will just add the characters "time()" at the end of the string and the query will produce an error.
-
I can't see anything wrong, but if it is printing from this line [code] $statement = "UPDATE sessions SET expiry = $expiry, value = '$value' " . "WHERE sesskey = '$key' AND expiry > " . time(); [/code] why not try putting that code all on one line, without the concatenation before the "WHERE", as you do not really need to have it split over two lines. I can't see why that would be a problem but if that's where it starts going wrong then it's worth playing around with it to see what happens.
-
What you need to do is look at the source HTML that this code outputs, and then you will see where you are missing opening <tr> and <td> tags.
-
Nope, still not clear. Do you mean you want to test to see if $_GET["p"] contains "name2" and "name3"?
-
You don't have any opening row or cell tags inside your while loop. Look at the code inside the loop - the first tag is a </td> - there is no corresponding opening <td> tag or even an opening <tr> tag. So your table is not complete, that's why it looks the way it does.
-
I would say that this condition [code] if ( (filesize($file1) <= 20480) && (filesize($file2) <= 26214400 ) && fwrite($commentsfile,$comments) ) [/code] is failing, meaning that either filesize($file1) is greater than 20480 or filesize($file2) is greater than 26214400 or fwrite($commentsfile, $comments) failed. If you look at your code you will see that if this condition fails there is no text output.
-
You used it in this line [code] $query_count = "UPDATE XXX SET hits=hits+1 WHERE id=$id"; //Note: $id is an auto_increment col [/code] but I can't see anywhere in your script where you've set it.
-
Where are you getting the $id variable from?
-
Menu options should have a closing tag </option> after the option text.
-
You are certain the cookie is set on the client machine?
-
php and mysql problems...need help with a query---figured it out nvm
king arthur replied to VTS's topic in PHP Coding Help
Does the table only contain data for one week, which you want the totals for? Or is there data for more than one week, and you want the totals for each? -
Posting to MySQL, then getting the row number?
king arthur replied to dagnasty's topic in PHP Coding Help
If you have an auto_increment field in the table and you want to know what the last value was set to, it's just mysql_insert_id(). You must have one and only one auto_increment column. -
Triple equals means "is identical to", not just "is equal to". For example if you have a numeric variable returned from a function, and "false" means no value returned, the problem is that zero could be interpreted either as the value zero, or false. But by using if($value === false) you can test the variable correctly.
-
I would say for starters, this line [code] //If the user has already voted on the particular thing, we do not allow them to vote again $cookie = "Mysite$id"; [/code] was actually meant to be two lines: [code] //If the user has already voted on the particular thing, we do not allow them to vote again $cookie = "Mysite$id"; [/code] as, at the moment, the variable $cookie doesn't appear to be defined in your script. Also, what should "Mysite$id" be? I think you need to change this to a string value that identifies your site.
-
Not 100% sure but you might need to put the time() function call in brackets when it's in the middle of a string.
-
How are you storing the users and their scores, and how do they access the hints?
-
[quote author=hackerkts link=topic=102443.msg406505#msg406505 date=1154357647] Ok, thanks for the explaination. And I still think he should use a cookie instead of session, since you can set the seconds until the cookie ends and will redirect to other page as marshall mention. [/quote] You can certainly set the time until a cookie expires but it still won't cause anything to be redirected.
-
If you mean a rotating banner that changes every few seconds while the user is viewing the page, then no, you will need to use javascript to do this.
-
Looks like this is your problem. [code] $members = mysql_connect("localhost", "lov3dco_users", "PASS"); if(!$users) //error checking :D { echo "<p>Sorry! We could not log you in at this time. Please Try again later!</p>"; } [/code] You've assigned the result of the output from mysql_connect to a variable "$members" but then tested for existence of a variable called "$users", which obviously doesn't exist.
-
You are going to have to either put the results into an array with the value in $date_seconds as one of the fields, and sort the array on that field to group the results by the date, or redesign your database so that you have a column with the date stored as a timestamp, then you can just add "ORDER BY your_date_column DESC" onto the end of your query.
-
The way I do it is to have a call to an authorize function near the start of the script for each page that is restricted to members only. The function returns true or false and does three things. First it checks to see if the user is logged in. If so it returns true. If not, it checks to see if a valid username and password was supplied, and if so it logs the user in and returns true. Otherwise it renders a login form and returns false - the "action" parameter of the form is set to the same page as the calling script using the $SERVER["PHP_SELF"] superglobal. On return from the function, if the return was false, I just end the script there instead of rendering the rest of the page. So, as soon as the user successfully logs in they will be returned to the same page which is then rendered fully. It works for me, it may not be the way everyone does it.