-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
I'm going to guess that your code is not even calling the Add_To_Queue() function in the first place. Your code executed as expected when I tried it with a call to the Add_To_Queue() function. When you post a small part of your code out of context it is just about impossible to tell you why your code does not work.
-
You have got an existing active thread for this. Don't start another thread for the same problem.
-
Upgraded to 5.3; setting the value of a variable with include file
PFMaBiSmAd replied to mrherman's topic in PHP Coding Help
Post your code that demonstrates the problem, showing the opening php tag being used in each file. -
If you had read your previous thread on this, you would have learned the correct way to add/subtract time from the current datetime - $ttldate = date('m.d.y', strtotime('- 3 day'));
-
Edit: Basically the same as above ^^^^ That's because your code is fetching and discarding the first row in the result set - $num = mysqli_num_rows($result); $row = mysqli_fetch_assoc($result); // ****** you are fetching and discarding this row ******* $counter=1; Why do you have that line in your code ^^^^^
-
Part of the point of using an array to hold a set of data that you will process is you can use array functions to loop over the data, such as foreach(), and if you happen to need to know how many pieces of date there are you could use count(). You would not necessarily write out all the individual lines of code that reference $data[0], $data[1], ... $data[x] unless you felt like you needed practice typing and you wanted to edit the code every time the amount of data changes.
-
Without knowing the table definition(s), seeing some sample data, and knowing what your database class methods are, you are right, it is probably not possible to come up with a solution that does this in a single query. But based on what your code does tell, your multiple calls to get the $club_name and $record_all would normally be handled by joining tables and adding the wins/losses would be handled by database count functions directly in the query.
-
No one can actually help you with what your code is doing without seeing all the actual relevant code involved with the problem. 113 different people could have written code that is attempting to do what you state and there could be something different wrong in each of their programs but each of them could produce the same symptom as your's.
-
My scripts won't connect to the server database....?
PFMaBiSmAd replied to gizmorattler's topic in MySQL Help
A) You have two many dots ... in your file path in the require() statement. It's two dots to go one folder closer to the disk root. B) You have not setup your database username and password to have access to any database. C) You are trying to mix mysql_ and mysqli_ functions. You must pick one type and use it for any particular connection. -
Each call to mysql_fetch_array(), fetched ONE (1) row from the result set. The while() loop you have seen in typical mysql code is there to iterate over all the rows in the result set. Is there some reason you are not using the mysql SUM() function directly in your query to produce the same result?
-
Just do directly it in your query when you retrieve the data - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff Use HOUR for the unit parameter.
-
Logged-in users seeing other users' information..
PFMaBiSmAd replied to dpedroia's topic in PHP Coding Help
The problem is because you are getting two different sessions because you are changing the URL between one that has a www. on it and one that doesn't. If you log in at www.yourdomain.com and log in at just yourdomain.com you will get a different event to show for that test account. You need to either cause your site to redirect non-www addresses to the www. version and/or set the session.cookie_domain so that it matches all variations of your domain. -
Logged-in users seeing other users' information..
PFMaBiSmAd replied to dpedroia's topic in PHP Coding Help
^^^ where are you setting the $user variable for the above query? Edit: And where in the mysa-events.php code are you verifying that the current visitor is logged in? -
Slight correction to the above, should this be from a query - ORDER BY Win DESC, Loss DESC
-
No it mustn't. You put code where it needs to be to accomplish the stated goal. Your loop is iterating over the result set. If you want each successive value to be concatenated with $variable, you must either do that inside of the loop or you must store all the values in an intermediate array and then concatenate them after the end of the loop.
-
PHP returns file as request, how to set name?
PFMaBiSmAd replied to cpuworks's topic in PHP Coding Help
To start with, the file name must be enclosed in double-quotes - header('Content-Disposition: attachment; filename="filename.doc"'); -
A) I can't help but wonder if this data is coming from a query, in which case you can simply do ORDER BY Win, Loss. And if this data is in a database and you are using a bunch of php code to come up with the Win/Loss values and the array you have shown, be advised that you can likely do this much easier directly in a query. B) If you must do this using an array in php, you can use array_multisort(), if you force the numerical [293] ... array indexes to be alpha-numeric associative names (so that php won't automatically convert them to numeric, in which case the resulting arrays will be re-indexed.) The following is the example from the php.net documentation for array_mulitsort(), modified for your example data - <?php $data = array(); $data['a293'] = Array ( 'Win' => 6, 'Loss' => 0 ); // the leading 'a' on the index forces these to be alpha associative index names $data['a298'] = Array ( 'Win' => 6, 'Loss' => 3 ); $data['a297'] = Array ( 'Win' => 3, 'Loss' => 3 ); $data['a302'] = Array ( 'Win' => 2, 'Loss' => 3 ); $data['a304'] = Array ( 'Win' => 5, 'Loss' => 3 ); $data['a295'] = Array ( 'Win' => 6, 'Loss' => 3 ); $data['a299'] = Array ( 'Win' => 2, 'Loss' => 3 ); $data['a292'] = Array ( 'Win' => 1, 'Loss' => 3 ); $data['a301'] = Array ( 'Win' => 3, 'Loss' => 3 ); $data['a294'] = Array ( 'Win' => 4, 'Loss' => 3 ); $data['a306'] = Array ( 'Win' => 2, 'Loss' => 3 ); $data['a305'] = Array ( 'Win' => 1, 'Loss' => 3 ); $data['a300'] = Array ( 'Win' => 1, 'Loss' => 3 ); $data['a291'] = Array ( 'Win' => 3, 'Loss' => 3 ); $data['a303'] = Array ( 'Win' => 0, 'Loss' => 3 ); $data['a296'] = Array ( 'Win' => 0, 'Loss' => 3 ); // Obtain a list of columns foreach ($data as $key => $row) { $win["$key"] = $row['Win']; $loss["$key"] = $row['Loss']; } // Sort the data with win descending, loss descending // Add $data as the last parameter, to sort by the common key array_multisort($win, SORT_DESC, $loss, SORT_DESC, $data); echo "Sorted data array:<pre>",print_r($data,true),"</pre>"; ?>
-
These are both server side so why does it not work
PFMaBiSmAd replied to stuckwithcode's topic in PHP Coding Help
The $_COOKIE['random'] variable is set by the browser when the browser requests the page. -
You would use an array (each value is an element in the resulting array) - "SELECT * from table WHERE client_id = '1'"; $data = array(); // define as an empty array while ($row = mysql_fetch_array($query)) { $data[] = $row['p_net']; // add each value as an element to the array }
-
You would need to echo the value that mysql_error() returns.
-
An even faster version - UNIX_TIMESTAMP();
-
If you were doing this on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini, all the errors that php detects will be reported and displayed. You will save a ton of time. There would be a error for the problem that YourNameHere pointed out and there would be an error when the unlink() statement executes as well because you put single-quotes around the string in it and php variables are not replaced with their value when enclosed in single-quotes, but they are when enclosed in double-quotes.
-
No, for at least two reasons. First, you have double-quotes around "home || about || contact". That is checking if $tag is equal to the string 'home || about || contact' Secondly, without the quotes, you would be or'ing home with about and then or'ing that with contact and that as a logic expression is equal to TRUE. So you would be checking if $tag is a TRUE value and that would be true for a lot of different values. Computers don't apply the distributive property to what you write. You must explicitly write out the logic test that you want or find a different method. Since you are testing if something is any one of a list of values, it would be easier to put those values into an array and use the in_array function.
-
Define excessive? What kind of problems do you have with the site? Have you already optimized the queries you do have? Unless you identify what is causing a problem, you cannot fix it because when you randomly attempt things, they won't address the root cause of the problem.
-
Your column names are enclosed in single-quotes, thereby making them strings instead of column names. Remove the single-quotes from around the column names.