-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
The $id not being set in that particular query won't produce an error, but since that query is inside the if (isset($_GET['id']) ) { conditional statement, that's not the problem anyway. However, that query is failing due to an error of some kind. You have another bad habit you need to break, nesting a mysql_query() statement inside of another function call. That prevents you from directly using any error checking and error reporting logic on the query to get it to tell you if or why it is failing before you attempt to use the data it is supposed to return. Break out the mysql_query statement, execute it first, with some error checking and error reporting logic - $result = mysql_query("SELECT * FROM `content` WHERE `id` = '$id'") or die(mysql_error()); $row = mysql_fetch_array($result); Since it would appear that you want to get the data from your table and put it into the form, regardless of if the form has been submitted, you would want to put that code back where you originally had it, after the end of the if (isset($_POST['submitted'])) { } conditional code.
-
http_build_query expects either an associative array, a numerically indexed array, or an object containing properties. What does $nbt->root contain?
-
force download script failing with PDFs.
PFMaBiSmAd replied to spiderwell's topic in PHP Coding Help
Have you checked directly if the offending .pdf file is a complete valid file? Perhaps it is only one byte? -
The following is your query in the first piece of code, that is producing the <img ...> tag - $query = "SELECT `picid`, `pic_name`, `pic_type`, `pic_size`, `picture` FROM mypictures ORDER BY `picid`"; The only piece of information you are using in the first piece of posted code is the picid column. That's the only column you should be selecting in the query. You both don't need the `picture`data in that piece of code (you need it in the viewimages.php code) and I already explained the downside of selecting the `picture`data in the first piece of code. If you are getting "Resource Id #5" displayed by the viewimages.php code, that means you are either echoing the $result variable or you somehow inserted a result resource name into your `picture` column. Post your actual code for viewimages.php (if it is different from the first post in this thread) and post the code you used to insert the actual image data into the `picture` column. What do you see in the `picture` column when you examine the database table directly using your favorite database management tool (phpmyadmin or similar)?
-
Reset the result pointer back to zero using - mysql_data_seek
-
You haven't exactly stated what about it does not work. Is the data displayed on the page? Can you click on an item and drag it to a new position? Is the updated position not being saved to the server so that the next time the data is displayed it is back to the original starting position? Define: 'it quits working' so that someone who is not standing right next to you could help you with what you saw when you try it. Can you post a link to the site? Does your page require you to be logged in (for all we know you have disabled cookies from your live domain in the browsers that it does not work in and you are not actually logged in.)
-
Since your `time` column is a mysql TIMESTAMP with a format of YYYY-MM-DD HH:MM:SS, why are you trying to compare that with a Unix Timestamp form php's time() function? Those are not even in the same formats and would never compare correctly.
-
What litebearer is suggesting that you do is to confirm that the <img src="..... HTML that is being output in your page is correct and has expected ?id=x values. If the `picture`column is your BLOB data, you should NOT be selecting that in your first code, because that would be retrieving all the image data for all the rows in your table, but throwing it away. That adds unnecessary processing time and consumes memory, both on the db server and in your php code. You need to troubleshoot why your code is not working, because you could try dozens of different scripts and they could all have the same problem, because the problem could be something on your server or something that your editor is doing when saving the file. To troubleshoot what your viewimages.php code is doing, add the following two lines of code immediately after the opening <?php tag (edit: in viewimages.php) and temporarily comment out the two header() statements - ini_set("display_errors", "1"); error_reporting(-1); Next, browse directly to the viewimages.php?id=x page, with a valid image id for x, so that you can directly see the output that is being produced.
-
The second problem with what you are doing is that date/time values in the past are smaller/less-than later date/time values. To find rows where the `time` field (assuming this is a mysql DATETIME value) is older than (already gone past) two days ago, you would first need to form a date/time that is two days ago (i.e. 2011-08-13 14:45:10), and then test if the `time` field is less-than that value. The WHERE clause would look like - WHERE `time` < '2011-08-13 14:45:10' The above WHERE clause will match rows with `time` older than two days ago. Rows with `time` greater-than or equal to two days ago will not be matched and will remain in the table after you perform the DELETE query.
-
To start with, the date() format you are producing cannot be used in a greater-than/less-than comparison, because the h (12 hour) and a (am/pm) format does not produce a string that can be compared with another string and give the correct results. Comparing 2011-08-17 02:45:10 pm with 2011-08-17 03:45:10 am (differences between the two values are in red) will indicate that the second (earlier value) is greater than the first (later value) because 03 (the hours) is greater-than 02. You would need to use a format like 'Y-m-d H:i:s' (which is a mysql DATETIME value) and the `time` column in your table would need to be the same format as well (hopefully it is already a mysql DATETIME field.)
-
No one here asked what the session.name is set to. However, someone has been asking you specific questions, twice for one of them, that would pin down what could be causing the problem. Without specific feedback from you to let us know what you are doing (urls/paths) and what part might be working (such as getting the session id cookie in your browser), no one here can help you.
-
If you didn't get any session_start related php errors, it is likely that the session is being started, assuming your session_start statement(s) are being executed in your code. Any chance you are using short open tags in some included files so that part of your php code is not being seen as being php code? Are you getting the PHPSESSID cookie in your browser? What about this question that was asked - Also, any chance that the path to the page with the code you posted is different than the path to the auto_quote2.php page you are redirecting to?
-
On both the page you posted the partial code for and the page you are redirecting too, add the following three lines of code immediately after the first opening <?php tag and tell us if there are any php errors reported when you try your code - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(-1); Also, is there any chance that you are redirecting back and forth between pages that have and don't have the www. on the URL?
-
Your forgot to tell us what problem, error, or symptom you are seeing in front of you that leads you to believe that it does not work.
-
You would need to post the actual query you tried and what result you got.
-
You need to (always) use full opening php tags <?php so that your code will be portable between servers where you might not have the ability to turn on the short_open_tags setting.
-
Where you defined it is not the same variable scope where you are using it. In you need help determining why you are getting the error message, you will need to post all the code on the page that would be needed to duplicate the error.
-
For output on line one of a file (assuming you have removed any characters in the file that are before the <?php tag), see the last reply in this sticky post - http://www.phpfreaks.com/forums/index.php?topic=37442.0
-
The examples at the link that jcbones posted, clearly show how to save the image vs outputting the image.
-
Your editor is likely saving the file as a UTF-8 encode file with the BOM (Byte Order Mark) characters at the start of the file and that is causing a header error (you would be getting an error message stating that output is being sent before the session_start statement.) You should have error_reporting (always) set to E_ALL and for development display_errors should be ON and on a live server display_errors should be OFF and log_errors should be ON. If you are doing this on a development system, the suggested settings would be outputting all the php detected errors. On a liver server, the suggested settings would be logging all the php detected errors. If after seting the error_reporting/display_errors/log_errors settings, you are getting an error indicating output is being sent on line one of the file, you need to save your files without the BOM characters.
-
If there are no rows in the result set, your while(){} loop will be skipped (the while() condition will be false.) Your test of $num==0 is inside of the while(){} block of code and is never executed. You should test if($num==0) first, before the start of the while(){} loop. Since you are expecting either zero or one row from the query, you don't even need a while(){} loop. If there is more than zero rows (one) (not zero rows), just fetch that one row.
-
You would use the GD image functions and draw a string on an image - http://www.php.net/manual/en/function.imagestring.php
-
On the outside chance that you actually just have a list of words (that were searched for) that you want to changed into links if they are found in an article or story - <?php $str = "this is my test string and string is very long with so many words"; $search = "my|string|with|words"; $str = preg_replace("/($search)/is","<a href='/index.php?word=$1'>$1</a>",$str); echo $str; ?>
-
You would use preg_replace - <?php $str = "this is [my] test [string] and [string] is very long [with] so many [words]"; $str = preg_replace("/\[(.*?)\]/is","<a href='/index.php?word=$1'>$1</a>",$str); echo $str; ?>
-
Without the actual symptom or error you are getting that leads you to believe that - "... an 'edit profile' page and when i go to test it, it will not connect to the database.", it is not directly possible to help you with what your code is doing. We don't have access to all your code, your server, or your database, so we must rely on just the information that you supply in your posts.