-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
Problem redirecting browser to previous (referring) page ...
mikesta707 replied to odintheterrible's topic in PHP Coding Help
that header error happens when output (including any whitespace or html tags) happens before that line. IE echo "hi"; header("Location: somewhere.php"); would throw the same error. To be of more help we would have to see the code in question, but make sure you don't have any whitespace, html tags, or other output (print, echo, etc) before that line. Based on the error message, particular this part it appears the output is sent on line 9 (you can tell which line and file the output starts by from this string.) so check that line -
The first two errors are because whatever file your copy() function is pointing too doesn't exist. Make sure you update the file paths to reflect what they are on the new server. and the third error is a very common error that results in trying to send a header (using the header() function) after you have output something to the page (this means anything, from whitespace, to html tags). We would have to see some code to be able to help more though
-
if you let the user input what country they are from (from a drop down box or something) then you won't need geolocation. The data you get might be a little off (as a user can lie) but thats probably not a big deal. and No, you wouldn't need to have people sign up (obviously this depends on your comment system. I'm assuming anonymous posting is allowed) you would just have a drop down box with a bunch of countries listed. You can then make a folder with a bunch of images of the flags named after their country. In the drop down, each item's value could be the name of the image for that flag (without the extension). For example, the japanese flag could be in a folder called Flags/ and could be named Japan.jpg. In your drop down box, for japan you would just have something like <select> .... <option value="Japan">Japan</option> ... </select> then in the PHP script itself, you can use that value as the name of the file. I don't know how you store comments in your database, but you can either add html directly in the comment body, or have a column that stores which country they are from, then use that as the image source, like $q = "SELECT * from Comments Where ...."; //other sql stuff while($row = mysql_fetch_array($result){ //display flag $flag = $row['country']; echo '<img src="'.$flag.'.jpg" />'; // etc }
-
Well how exactly do you want it sorted? Can you provide an example of an unsorted array, then how you want it sorted? asort will sort it numerically (ascending) You can also get a descending sort with arsort. for example $arr = array(1,2,5,34,2,6,3,2,7,34,6,3,4,6); $arr2 = $arr; asort($arr); arsort($arr2); echo "<pre>"; print_r($arr); echo "</pre>"; echo "<pre>"; print_r($arr2); echo "</pre>"; ?> produces Array ( [0] => 1 [7] => 2 [1] => 2 [4] => 2 [11] => 3 [6] => 3 [12] => 4 [2] => 5 [10] => 6 [5] => 6 [13] => 6 [8] => 7 [9] => 34 [3] => 34 ) Array ( [9] => 34 [3] => 34 [8] => 7 [5] => 6 [13] => 6 [10] => 6 [2] => 5 [12] => 4 [11] => 3 [6] => 3 [4] => 2 [7] => 2 [1] => 2 [0] => 1 ) asort() arsort() if you are working with strings, or have a certain way of sorting in mind, then this might not work, but your first example has an array of numbers. If you don't sort them numerically, how else do you want to sort them....
-
you can do that a fews. The easiest (well easiest IMO) would be to just concatenate (or basically mush together) a string in the loop and just trim the last comma from it. while(...){ $string = "";//create an empty string if (..){ $string .= "Black, "; } if (..) { $string .= "Asian, "; //etc.. //trim last comma and space $string = rtrim($string, ", ");//use rtrim because we only want to trim from the right }//end while but there are multiple ways of doing it (and the method is pretty much the same (or similar) with the foreach or while)
-
wouldn't asort work for you? you seem to try to do it in that if statement, but you have it commented out
-
a foreach is used with arrays. In this case, I don't think a foreach would be the best option, but what exactly were you intending to do with a foreach? which array would you iterate through?
-
If you want to just pull only asians and blacks, or something like that, than I would suggest using WHERE clause. if you just want to list everyone, and say what race they are, than select the columns you needs and leave out the Where clause (since you want every entry) and use the if statements
-
I don't see the issue with this syntax; help?
mikesta707 replied to monkeytooth's topic in PHP Coding Help
you shouldn't use single quotes for numeric data types. try removing the single quotes -
can you post the code that does this so I can try it out?
-
track website search engine placement by keyword?
mikesta707 replied to michaellunsford's topic in Miscellaneous
Pretty sure GA does that for you -
seems like your query is failing. try adding or die(mysql_error()); on the same line as your query statement and see what it returns
-
Well if you don't have anything to show them, what suggestions are you looking for? ways to not show them something?
-
Automating form-to-database (and back) data handling.
mikesta707 replied to bluegray's topic in PHP Coding Help
The problem is $ld is a loop variable, and get overwritten everytime the foreach happens. What you probably want to do (assuming that the order of the array elements corresponds to the order of the columns in your insert statement) is to make a string $insert = "" foreach ($_POST ['listdock'] as $ld) { $insert .= "'"$ld."',"; } $insert = rtrim($insert, ",");//trim the last comma off the string and then you could use the insert string like so $query = "INSERT into blah blah blah VALUES($insert)"; -
np, if your topic is solved you can click the marked solved button at the bottom of the thread
-
Please help me revise this log in code.
mikesta707 replied to shinichi_nguyen's topic in PHP Coding Help
if both are empty then the or will still be true. And will only be true if both are empty, and he wants it to redirect if 1 OR both are empty. -
Looks like a crawler of some sort, or something that does some sort of crawling. You say you don't know how it got there? could your host have put it there? what kind of hosting do you have?
-
track website search engine placement by keyword?
mikesta707 replied to michaellunsford's topic in Miscellaneous
I think google analytics tells you where you rank on certain keywords. haven't used it in a while, but I believe I saw that somewhere when I was using it. its free too http://www.google.com/analytics/ -
what are those times in the strtotime() function supposed to be exactly? have you tried putting dashes or some other delimiter between the year/day/month?
-
the URL parameters are formatted incorrectly. When you send $_GET data, you append a ? at the end of the filename (IE page.php?) and then you add the variables (IE page.php?id=5) if you have multiple variables, after the first variable, you separate them with the ampersand (&) IE (page.php?id=5&other=6)
-
Please help me revise this log in code.
mikesta707 replied to shinichi_nguyen's topic in PHP Coding Help
No, he should use OR. Think about it, you want an error to occur if 1 OR the other is not set (or, 1 OR the other is empty). I don't see much of a problem (other than the fact that your code is formatted very strangely) Can you post the form you use to log in? try doing print_r($_POST); and see what $_POST data is being sent (and if the data being sent is what you expect it to be) also remember if you use an md5 (or other algorithm) hash on your passwords, you have to hash the password before you check it in the query -
as far as mysql goes, thats pretty much the only way to connect to a database. A lot of people make the database info (like $host, $user, etc) into constants rather than normal variables, but beyond that yeah, thats how you do it
-
Parse error: syntax error, unexpected T_VARIABLE
mikesta707 replied to Cruiz Risner's topic in PHP Coding Help
this line needs a semi colon $to = $_REQUEST['to']; -
can you post your full header statement?