-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Assuming that you are using a database abstraction class and that is how you are counting the queries, wouldn't you just add code to your ->query() method to log the actual queries somewhere? You could also use the debug_backtrace() function as part of that to get the actual file/line number where the query method was called at.
-
Because SUM() is an aggregate function that is rolling up all the results into one row. What result do you want to get?
-
Best way to code loops to display data - noob
PFMaBiSmAd replied to JohnHall35's topic in PHP Coding Help
<?php // execute your query here to get the rows you want in the order that you want them $last_heading = null; // variable to remember the last heading while($row = your_fetch_assoc()_statement){ // detect a change in the heading value and output the new heading/start a new section if($last_heading != $row['your_heading_column_name']){ // detect if it is not the first heading - close out the previous section if($last_heading != null){ // your code to close the previous section/table... echo "close section<br />"; } // output the new heading/start a new section here... echo "new section title - {$row['your_heading_column_name']}<br />"; // remember the new heading value as the last_heading $last_heading = $row['your_heading_column_name']; } // output the actual data here... echo "data - {$row['your_data']}<br />"; } // if there was any output - close out the last section if($last_heading != null){ // your code to close the previous table... echo "close section<br ?>"; } ?> The 'your_heading_column_name' in the above sample code would be your 'city' column name. -
There's really no way that the code you posted is producing those errors (you don't even have a mysql_fetch_assoc() statement in that code.) Please post the actual code that is producing the errors in order to get help with your code.
-
It's the browser that requests the image and as long as the URL is a valid URL to an image file, the browser can fetch it.
-
retrieve value from 3 dropdown menus which are the same name?
PFMaBiSmAd replied to zac1987's topic in PHP Coding Help
The $_POST variables will be - $_POST['dropdown][1], $_POST['dropdown][2], and $_POST['dropdown][3] You would typically use a foreach() loop - foreach($_POST['dropdown] as $key => $value){ // $key will be 1,2, or 3 // $value will be the submitted value } -
<?php $the_ip = $_SERVER['REMOTE_ADDR']; $query = "SELECT inet_ntoa(int_ip_low) as ip_low, inet_ntoa(int_ip_high) as ip_high FROM ip WHERE inet_aton('$the_ip') BETWEEN int_ip_low AND int_ip_high"; $result = $mysqli->query($query); if($result->num_rows){ $row = $result->fetch_assoc(); echo "Your IP: $the_ip is between {$row['ip_low']} and {$row['ip_high']}"; } else { echo "Your IP: $the_ip was not found"; }
-
You would use a BETWEEN ... AND ... comparison - http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between
-
That example is for the - 2.96.0.0/13 value and the 13 would change.
-
Here's a mysql query statement that would calculate that - select inet_ntoa(inet_aton('2.96.0.0') + (pow(2, (32-13))-1));
-
If you haven't actually checked at what point you have the expected data and at what point you don't, there's no point in wasting time trying to guess where the problem is. There could be a half-dozen different reasons your code doesn't work and you must narrow down the problem by finding out where your code and data is doing what you expect and where it is not.
-
OR the quotes within the string need to be changed to single-quotes.
-
Need help sorting an array - please help
PFMaBiSmAd replied to simboski19's topic in PHP Coding Help
For a general purpose method, you would use array_multisort(). Assuming that $data is an array of arrays and you wanted to sort by the 'price' field - $sort_field = 'price'; foreach ($data as $key => $row) { $sort_by_this[$key] = $row[$sort_field]; } array_multisort($sort_by_this, SORT_ASC, $data); -
PHP Login system driving me bonkers...
PFMaBiSmAd replied to FalseProphet's topic in PHP Coding Help
Your setcooke() statement in APNetwork_Login.php is not using the 4th parameter (the path the cookie matches), so the cookies only match the system/scripts/ path and the browser won't send the cookies to the server for pages in any other folder. You would want to set the 4th parameter to '/' so that it will match all paths. All of this information can be found in the setcooke() section of the php.net documentation. -
To get help with what you are trying to do, you would need to show exactly what you are trying to do and what the expected result should be.
-
A leading slash / on a file path refers to the root of the current hard disk. You would either use an absolute file path ($_SERVER['DOCUMENT_ROOT'] will get the base path to your document root folder) or you would use a file path relative to the current script (a file path starting with a ./ or a ../) or you would let php search the include_path setting to find the file (when neither an absolute or relative file path is given.) All of this information can be found in the php.net document for the include() statement.
-
php extension crashes apache
PFMaBiSmAd replied to otvilf's topic in PHP Installation and Configuration
Problems like this are usually caused when you use .dll files that weren't built for the exact version and flavor of php. Did you use .dll files that came with your php distribution or how did you obtain the .dll files? -
^^^ That's why you would do this on some test data first. In programming, it's generally going to take you a lot less time to make a test case and try your solution so that you can conform if it does what you expect, than what it will take to post a question in a forum somewhere and hope you get an accurate answer to your question. And if this is a one time update, you can just do it directly in phpmyadmin without needing to write any php code.
-
Conditional session garbage collection handling
PFMaBiSmAd replied to cranky's topic in Applications
There's no good reason to be doing this. In fact, by reducing the probability that garbage collection will run, as you add more users, when garbage collection does eventually run, it will have to take a greater amount of processing time because there will be more session data files to examine and a greater percentage of those will be old enough to delete and it will take more time to delete them. It is best to just leave the probability at a fixed and reasonable value. -
mysql_num_rows() expects parameter 1 to be resource, boolean given
PFMaBiSmAd replied to chicago's topic in PHP Coding Help
That would mean that the $sql variable itself is empty. About the only way(s) that could occur with the code you posted is if you have some non-printing character as part of the $sql variable name so that php is not seeing the same code that you posted or the code you posted isn't the actual code that is producing the error. For possibility #1, delete and retype the whole $sql variable name in both places in that code. For possibility #2, make sure the line number where the error is being reported at is the actual code you are showing us. -
How to output BLOB images through PHP to HTML ?
PFMaBiSmAd replied to anevins's topic in PHP Coding Help
Your current error is both because your query is failing due to an error of some kind AND you are attempting to use a mysql fetch statement with a mysqli query. To get php/mysql to tell you why your query is failing, (please) use some error checking and error reporting logic in your code - $result = mysqli_query($dbc, $query) or die(mysqli_error($dbc)); If you are using mysqli for your connection, you must use mysqli for all the operations using that connection. You cannot mix mysql and mysqli statements on one connection. -
Where are you trying to upload the file FROM and where are you trying to upload the file TO? What exact problem are you having with large files and how large are the files that don't work? Using a web based HTML form, implies that you are uploading the file from a client/browser to your server where your .php code is located. Adding ftp_xxxxx() statements in your code code implies that you want to send that file, after it has been uploaded to your server, to an different server by using FTP to transfer it. If the file isn't uploading to your server in the first place, trying to use FTP to transfer it somewhere else doesn't make an sense.
-
htaccess not loading? AccessFileName nonexistant!?
PFMaBiSmAd replied to Jbudone's topic in Apache HTTP Server
Do you have an AllowOverride setting in your httpd.conf file that would allow the .htaccess file to change any settings? -
A) Your mysql_connect() statement that you think is working 100%, isn't. The 4th parameter of it is not the database name and you are not getting an error from it because php thinks you are trying to force a new link to be created. B) The error you are getting from mysqli_connect() is telling you what the problem is. C) Therefore, it is likely that your database name is not 'example'