Maq
Administrators-
Posts
9,363 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Maq
-
Help needed - Fatal error – function not defined
Maq replied to lesterdan's topic in PHP Coding Help
K, this is the wrong code because the function, "get_user_by_id()", isn't called in your code. Use code formatting tags! (the icon with the# sign) -
Doctortim, haku is right. The reason you're not getting any help is because you are being rude and posted in the wrong section. You probably posted this in the PHP Help section because it has the most traffic, which is ignorant, and that's how you are treated. We're here to help, it's not like we get paid commission for every solution we provide... Correct protocol? Isn't that quite obvious? You state your question (in the right section!), with enough information for people to help you, and wait for an answer. If someone is rude, which they really weren't, just ignore them.
-
1) To prevent counting when a user refreshes the page, use sessions. You can set a session variable to check if they have already hit that page or whatever you're trying to do. Most of what you're trying to do in perl is similar to PHP. session_start(); $_SESSION['stats'] = (isset($_SESSION['stats'])) ? $_SESSION['stats']+1 : 1; if($_SESSION['stats'] > 1) { //they refreshed the page or came back here } else { //it's their first time here; your code here } 2) You can use something like this (from the manual www.php.net) to check what browser they're using: function get_user_browser() { $u_agent = $_SERVER['HTTP_USER_AGENT']; $ub = ''; if(preg_match('/MSIE/i',$u_agent)) { $ub = "ie"; } elseif(preg_match('/Firefox/i',$u_agent)) { $ub = "firefox"; } elseif(preg_match('/Safari/i',$u_agent)) { $ub = "safari"; } elseif(preg_match('/Chrome/i',$u_agent)) { $ub = "chrome"; } elseif(preg_match('/Flock/i',$u_agent)) { $ub = "flock"; } elseif(preg_match('/Opera/i',$u_agent)) { $ub = "opera"; } return $ub; } ?> 3) For the IP, you can use: $_SERVER['REMOTE_ADDR']; 4) For the host name you can use: $_SERVER['REMOTE_HOST']; It looks like you're storing this information in a file, so you're going to want to look at the file input/output methods from the manual. The majority of what you need for user statistics you can find here, in the manual.. Hope this helps!
-
Relax, we're here to help. If a thread is in the wrong section then click on the "report to a moderator" link and tell them which section to put it .
-
Haha yeah, gotta love the open vs closed source battles.
-
Asking for help on your homework is perfectly fine in my book. I agree with corbin, he's not going to learn anything and only be a detriment to the programming community, if he doesn't do things himself... @crossfuse, you have your form correct and you grab the value correctly but you need to check if it's an odd number. A good way to do this is with the modulus operator(%). Try to implement this piece of code into yours. And if you don't know how it works just ask, and I'll give you a detailed explanation but basically it's called a Ternary Operator (essentially a 1 line if/else statement): $total += ($x % 2) ? $x : 0; $x is the number that you're looping and if it's odd then add it to the total. Hope this helps.
-
That, and post your current relative code.
-
What exactly are you stuck on?
-
That's for addition. We're concatenating strings here, so use ".=" like in my previous post.
-
You need to use double quotes for $option: $option = "'$arr"; I think you're using too many loops as well... $status_array = array('Pending', 'Followup', 'Approved', 'Completed', 'Rejected', 'Correction'); foreach($status_array as $arr) $option .= "$arr";
-
To find out how many records are in your table, you can use the aggregate COUNT() function: $sql = "SELECT COUNT(*) AS num FROM table"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($result); echo "There are " . $row['num'] . " records in your table";
-
Found this on Google. Looks like it may help you out creating a good design. Not sure if it's any good but it's worth taking a look at, and it uses sockets. http://www.raditha.com/php/ftp/ EDIT: Just saw you wanted a server, not a client. I'll leave this up just in case you find it useful. * Searches google again *
-
$numds = ($numds == 0) ? 1 : $numds;
-
What does the error message say? I'm confused... In the statement above you claimed you were using sessions, but in your code you don't use them. If you're referring to this line, that's not using sessions. $user_id = $_REQUEST['uid'];
-
Where? I don't see any trace of sessions in your code. Couple things I noticed: 1) Don't use short tags () always use <?php 2) Make sure you put "session_start();" at the top of your page before you assign the id from the session.
-
Before we proceed, you're assigning $grab = $_GET['grab']; before you do the ifelse, right?
-
Change this line to (it will give a more descriptive error message) : mysql_query ($query, $linkme) or die (mysql_error());
-
You weren't telling MySQL what tables the fields came from. You could have done something like this: $result = mysql_query("SELECT * FROM diary d LEFT JOIN customer c ON c.customer_id = d.customer_id WHERE d.diary_id LIKE '$_GET[searchterm]'"); FYI: You should really sanitize your values before you put them in a query, even though it's an integer, it's still a good practice to use mysq_real_escape_string().
-
Sorry not sure what you mean or where the other array comes from. Could you post the print out of both arrays you need to combine, and what you want the resulting array to look like using "print_r($array);" perhaps?
-
So... problem [sOLVED]?
-
You also posted this in the wrong section (do not start a new one), you probably meant to put this in the "PHP Math" section. Also, please use tags for you code.
-
Sure, it's weird because I've seen this same question like 3 times last week.
-
You probably want to just download a third party script for this. To my knowledge, there is no function that can detect this. Google "php ip to country". Good luck.
-
We learn from our mistakes, at least if something like this happens again you'll know what most likely problem is (hopefully) If this solves your problem please mark as [sOLVED].