-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Edit: Basically the same as what WT88 wrote ^^^ mysqli_query() returns a result set that you must fetch data from, assuming your query returned any matching rows. There are a family of mysqli_fetch_xxxxx() statements you can use to do this. Your variables $h1 and $h2 are not data. You cannot directly use count() or access data elements in them. I recommend reading a mysqli tutorial or the examples in the mysqli section of the php documentation to learn how you would execute a query and fetch the data it returns.
-
It's likely that your localhost/development system has output_buffering turned on in your master php.ini and so allowed you to crate code that would not work on the greatest number of web hosts where you might not have the ability to turn on output_buffering. If output_buffering is turned ON on your localhost, I recommend turning it off and getting your code to work again on your localhost before putting it onto your web host. Another common problem is that not all the settings needed for sessions are setup correctly on your web host (typically the session.save_path is not set to a valid folder.) Temporarily add the following lines of code immediately after your first opening <?php tag and before any php code in your main file to see if there are any errors when session_start() is called - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(E_ALL); Is this the first time you have attempted to use code on your web host that uses sessions or does other code that uses sessions work and it is only your current code you tried that does not work?
-
For Loop Only Storing Some Entries in Database
PFMaBiSmAd replied to Elven6's topic in PHP Coding Help
Your code appears to be using an $i variable to make/access a sequence of named fields (which is never a good idea) AND you are attempting to make that field an array (which is the best way, however, your [] are outside of the field name attribute and probably don't work.) While that might make sense for sets of sets of data, your form processing code clearly cannot work because you are using the same $i variable in the for(){} loops that you are using to get the count() as the limit of the loop. You need to start by defining what you want as your data, then make sure your form is correct, and that the data submitted to your form processing code is what you expect. -
Just use an array in the first place. Why you might ask? Because you can then reference the data using array functions and you don't need to keep track of how many sequentially named variables you created or what their names were. Also, using variable variables is three times slower than using array variables.
-
Why not. The end of life of php4 was over two and half years ago. You should have upgraded a long time ago.
-
You MUST ALWAYS validate external data. If $_GET['cat'] didn't have a value in it or it was not numeric, you should have never executed the query.
-
It would really help if you told us what it did do - a) Produced a sql error? b) Executed without error but matched zero rows? c) Returned the wrong rows?
-
You would need to separate the logic for the 'delete' operation from the logic for the 'insert' operation. You apparently took some 'insert' code and added a delete operation inside of it.
-
Your 'delete' forms only set the 'isbn' and 'delete' fields, so it will be a little hard for the above ^^^^ code to ever be TRUE.
-
Anyway of Decrypting a md5 Password? Forgot PW Form - HELP
PFMaBiSmAd replied to oliverj777's topic in PHP Coding Help
LOL, since md5() isn't encryption, there is no way to decrypt it. It is a one-way hash (checksum.) -
Can't display text from MySQL on page
PFMaBiSmAd replied to brendansingleton's topic in PHP Coding Help
That error is probably referring to the line with - $row["body"] That either means that the query matched zero rows or you don't have a column named body in your table. Since you are checking mysql_num_rows, it's likely that you don't have a column named body. However, you do need an exit; statement after your header() redirect to prevent the rest of the code on the page from executing while the browser is requesting the new URL in the redirect. You should also check in your logic if $page_name has a value before you blindly put it into a query and execute that query. -
How to use variables from other included files
PFMaBiSmAd replied to georgefl's topic in PHP Coding Help
Just post your actual code to get the quickest help with why it is not working. There's several million php web sites where what you are doing works. Either your include statements are failing or the few lines of code you posted out of context are either not being executed or they have a different variable scope from where the variable is set. -
So, when you were debugging this to find out what execution path your code is taking and what the data was at the different points along that path, at what point did you find you had the expected data and at what point did you find you did not? I can guarantee that the problem lies between those two points.
-
Since the code you posted does not contain a mysql_fetch_array() statement, it would be a little hard to directly help you. Try again. Once you identify the actual code where the error is occurring, that error normally means that your query failed due to an error and your code has no error checking logic in it to both tell you that the query failed, what the error is, and to prevent the rest of the code from blindly attempting to access data from a failed query.
-
Must be by some ex MS programmers. Produce something that looked good when you showed it to your boss and met the deadline, but don't bother testing it to make sure it actually worked correctly for the people who would actually use it.
-
Apache PHP extension problems in Win Vista
PFMaBiSmAd replied to MrCalapo's topic in PHP Installation and Configuration
Any chance that when you edited php.ini that it got saved as php.ini.txt? The only thing that stands out in the information so far is that the loaded configuration file is none, which means that php is using all the default values. Beyond that, problems like this are usually permission problems. You should check the web server error log and your Windows event log for any startup errors that would help pin down where the problem is. -
Can't display text from MySQL on page
PFMaBiSmAd replied to brendansingleton's topic in PHP Coding Help
Your symptom changed from the first post in the thread (where you were getting a valid link resource) to reply #2 (where you are getting a fatal runtime error.) What is your current symptom/error and the corresponding code? And you should always have error_reporting set to at least E_ALL and display_errors set to ON on your development system so that all the errors php detects will be reported and displayed. -
Your getimage.php code doesn't contain any code to make the connection to the database server or select a database. If you were testing this on a system with error_reporting set to E_ALL and display_errors set to ON and the header() statement was temporarily commented out, you would be seeing the php detected errors. There's also no point in using the following two lines of GD code because you are not manipulating the image using GD functions (actually you are because the default image quality is 75% so using imagejpeg is reducing your image quality) - Also, imagejped() in the above code OUTPUTS the image data. So, remove those two lines of code. At a minimum, your code should - 1) Make a connection to the database server and select your database. 2) Get and validate/escape the $_GET['id'] value. 3) Query the database to get the image data and the image type. 4) Retrieve the data from the result set. 5) Form and output the content-type header using the image type gotten from the database. 6) Output the image data.
-
Apache PHP extension problems in Win Vista
PFMaBiSmAd replied to MrCalapo's topic in PHP Installation and Configuration
What method did you use to get and install php? The .msi installer or the .zip package and manually install it? Does the gd extension show up in the phpinfo() output? Is the php_gd2.dll actually in the ext folder? Have you successfully installed any other php extensions? -
MySQL strangeness, table saves intermittently...
PFMaBiSmAd replied to xtian's topic in PHP Coding Help
A) Is this repeatable. The same data produces the same result? B) What are the test email address that are failing? C) It sounds like you are doing client-side validation. You must ALWAYS do server-side validation once the data reaches you server. D) How about checking what data is actually being submitted to the php script with the following - echo "<pre>"; echo "POST:"; print_r($_POST); echo "</pre>"; -
showing a month from a selection of dates.
PFMaBiSmAd replied to runnerjp's topic in PHP Coding Help
I'm not sure where I got the idea these produced links. Anyway, the DATE_FORMAT() parameters are the date as the first parameter and the format parameter is second. I would do it this way - $start = '2009-01-01'; // start of data to look at $end = '2010-08-25'; // end of data to look at $query = "SELECT DISTINCT YEAR(event_date) as year, UPPER(MONTHNAME(event_date)) as month FROM your_table WHERE event_date BETWEEN '$start' AND '$end' ORDER BY event_date"; $result = mysql_query($query) or die("Query failed: $query<br />Mysql error: " . mysql_error()); $current_year = ''; while($row = mysql_fetch_assoc($result)){ // test for a change in the year if($current_year != $row['year']){ echo $row['year'] . '<br />'; $current_year = $row['year']; // remember the new year } //echo "<a href='?year={$row['year']}&month={$row['month']}'>{$row['month']}</a><br />"; // in case you wanted links echo "{$row['month']}<br />"; } -
http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html Read, as you might imagine, and the point where the error occurred, is a reserved keyword. Either rename your column to something else or enclose read in back-ticks `` every time you use it in a query.
-
showing a month from a selection of dates.
PFMaBiSmAd replied to runnerjp's topic in PHP Coding Help
I think he wants to get the discrete list of months that exist in the data (probably over a specific date range) so that he can produce the month links (or perhaps year/month links). -
The query that retrieves the rows to be displayed on any page, very specifically used a LIMIT clause to accomplish getting the correct rows - Your query would need to do the same.
-
See the correct HTML syntax at this link: http://w3schools.com/tags/att_option_selected.asp