ggkolfin Posted April 3, 2016 Share Posted April 3, 2016 Hello everyone, I am not sure if this is the right place to post since I do not know for sure if it is PHP that causes my issue, so I apologize in advance if I shouldn't have posted here. I am using WampServer Version 3.0.0 64bit (Apache: 2.4.17 | PHP: 5.6.16 | MySQL: 5.7.9) on windows10. I am updating a website and I am keeping the database the same, except from some small optimizations here and there. I have a query that selects all active rows of a specific category, then I fetch the results and show the rows: if(mysqli_stmt_prepare($stmt, "SELECT * FROM myTableName WHERE _category=? AND _approved='1' ORDER BY _id DESC LIMIT ?, ?")) { mysqli_stmt_bind_param($stmt, "iii", $category, $offset, $rowsPerPage); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt,$id,$title,...,$image,...); //all fields are binded, including image while(mysqli_stmt_fetch($stmt)) { //show recipes } } The query is correct and everything shows up fine, except from the image returned by the query. My old database used to store the image with the path, eg "/this/is/the/path/to/image.jpg" but I have updated the image table column to only store the file name so now $image variable should contain only the file name, eg "image.jpg". But it does not. The $image variable still contains the full path, although the table is updated! I though it was some kind of caching, but clearing the browser's cache, going incognito, hard refreshing, changing browser did not change anything. I also tried running: SET GLOBAL query_cache_size = 0; in mySql terminal but that did not change anything as well. I also tested php.ini for Op Cache but it was already disabled: opcache.enable=0 I do not know what to do about this and it is driving me crazy! Any help will be very much appreciated. Thank you all, georgia Link to comment Share on other sites More sharing options...
Don E Posted April 3, 2016 Share Posted April 3, 2016 Hello, Is each record (row) for the image column in the database table updated to just the image names? Have you looked at the table itself in phpmyadmin to see/make the changes... or to actually see if the changes were made? Are you getting any errors anywhere? I am sure you are but make sure you are connecting to the database that has the newly updated table incase you may be connecting to the old database that has the long image path column table. If after you made the changes and you have inserted new images (image names) into the table with your insert command still containing the path to the image name instead of just having the image name, you may want to see to see how your INSERT command looks like so that it only has the image name for the image. Link to comment Share on other sites More sharing options...
ggkolfin Posted April 3, 2016 Author Share Posted April 3, 2016 Hi Don E, Thank you for your reply. Yes, the database is updated, I have checked in phpmyadmin, I am not getting any errors. There is only one database to connect to, the one with the updated names so I am positive that I am connecting to the right database. When I try to insert a new row the image is saved correctly into the table (file name only) but the new entry does not show up in the front end, as if nothing has been added to the database. So it seems that it is not limited to the images. It looks like caching is involved but I cannot figure it out. Any ideas? Link to comment Share on other sites More sharing options...
Don E Posted April 3, 2016 Share Posted April 3, 2016 (edited) Try another browser in regards to caching and see if you get anything. For testing and simplicity sake, I would do a simple Select all. It may be an error with the prepare, binding param, bind result. Are you checking for mysqli errors? See if this is returning true or false: while(mysqli_stmt_fetch($stmt)) { //show recipes Check this as well, true or false. Add an else clause to it so that if it's false, it'll enter the else clause and echo something out to indicate it's false like, echo 'entered else clause, prepare is false'; : if(mysqli_stmt_prepare($stmt, "SELECT * FROM myTableName WHERE _category=? AND _approved='1' ORDER BY _id DESC LIMIT ?, ?")) Edited April 3, 2016 by Don E Link to comment Share on other sites More sharing options...
dsonesuk Posted April 4, 2016 Share Posted April 4, 2016 Why not copy table with '_r' ( revised) at end of name, use that name to see if it works as it should, keep original as backup. Link to comment Share on other sites More sharing options...
ggkolfin Posted April 4, 2016 Author Share Posted April 4, 2016 Code wise everything works fine - I do not get any errors nor anything returns false. The browser caching is not to blame either. As I mentioned in my original message, I've tried everything to clear the browser's cache and tried different browsers too, but no difference was made. @dsonesuk, I tried copying the entire table and used the new table instead and everything seemed fine. When I added a new row at the new table though, the new entry did not show up in the front-end. Again, I can only assume that there is some caching going on, and I am not referring to the browser's caching... Any ideas? Link to comment Share on other sites More sharing options...
justsomeguy Posted April 4, 2016 Share Posted April 4, 2016 Why do you think caching is the problem instead of a code issue? It sounds like you've cleared every cache imaginable, so why do you still think that's the issue? I assume inside the loop where you print the database records you're also printing the title or something else that would appear on the page, you're saying that you're not seeing any of that information appear? If you're seeing everything but the image appear, then have you checked the HTML source to see what URL you're printing for the image? Link to comment Share on other sites More sharing options...
ggkolfin Posted April 7, 2016 Author Share Posted April 7, 2016 @justsomeguy, the code displays everything correctly -just not the current version of the data, an earlier version. If I add a new row now it will not show up at all: neither the image, nor the title/the description/etc, nothing will show up in the front-end as if the row was not in the table. I first noticed the issue with the image field because it was the one that was updated. When I manually (through phpmyadmin) change some data in my table, the change is not picked-up by the front-end. The previous data is still getting shown. This says "caching" to me. Maybe I am wrong, but I am not getting any errors from the queries, I just get old data... Link to comment Share on other sites More sharing options...
justsomeguy Posted April 7, 2016 Share Posted April 7, 2016 Are you sure that your application is using the correct database, if you have multiple databases? Maybe you're changing the wrong database. Link to comment Share on other sites More sharing options...
ggkolfin Posted April 10, 2016 Author Share Posted April 10, 2016 @justsomeguy, it seems you are right. I changed the password of root user for phpmyadmin (through phpmyadmin -> my_database -> privileges -> edit privileges -> change password AND I changed the $cfg['Servers'][$i]['password'] in C:\wamp64\apps\phpmyadmin4.5.2\config.inc.php to have the new value) and now I cannot get to connect to the database any more. The code line: $link = mysqli_connect("localhost", "root", "[mynewpassword]", "my_database"); returns "Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)" (I can still manually connect to the phpmyadmin though). But when I try: $link = mysqli_connect("localhost", "root", "", "[myDatabase]"); //no password, like it was before it does connect somewhere and returns the same data as always, which is probably not the right place. So I am assuming that I was always seeing the data from another place and that is why my manual changes did not show up in the front-end...??? I still don't get it though. I used to host this site on goDaddy but it is not there any more. Is it possible that my site is trying to connect to another place and not phpmyadmin? And how can I check for that? (Sorry it takes me so long to answer, I am between different places these days and I do not always have access!) Link to comment Share on other sites More sharing options...
dsonesuk Posted April 10, 2016 Share Posted April 10, 2016 Is the new database set for access for specific user only. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now