I'm new to the world of databases and I've just started making my first DB powered site with php and MySQL.
I've got it working with data from one table but now I need to get a url to the users school, which is in a second table. Based on which school the user has saved in the first table. Everytime I try this method: http://www.w3schools.com/php/php_mysql_select.asp inside the registered.php the whole page goes blank. The connection to the database is made from a connect.php file which I included in both index.php and registered.php
Explanation, the user logs into the page at index.php, that page sets a cookie with the users school which it gets from the users table. The user gets redirected to registered.php where I want to get the school's url (and some more things) for the users school. It's very hard to explain, I hope you get it..
Thanks in advance!
I'd say that you have a problem in your PHP and not the database... you have some syntax error in your code and that's why you see a blank page. If you're doing this on your own machine, for development and debugging purposes you can configure PHP so that it prints errors out directly to the screen when you open the page in your browser instead of to the log.
You should also probably rethink your design as you should probably not store user details into a cookie (why not in $_SESSION, for example?), but I don't think that's a subject for this board...
Related
I got into a problem and I don't exacly know what's wrong.
I had a mysql database that stores the data for a website on a server and I exported it into the website hosting server with a new table added for users that is needed for login. The data that I upload is stored in another table called data.
When I upload a photo with and some text as description everything gets uploaded correctly and in the specified folder location. I can even see the data in the table using PMA.
The problem is when the site is rendering the data, it does render the text that I upload but not the photos. For anything that is media I receive a 404 error an I really don't understand why...
Any help or tips is greatly welcomed.
Thanks.
After I changed the URL key in Category management in Magento from "shop" to "webshop"and later changed it back to "shop", the url of the category page now shows up like /shop-3.html Is there a way to go back to the original /shop.html?
FOUND THE SOLUTION: http://www.youtube.com/watch?feature=player_embedded&v=8xttr_ILd6A
Sometimes when you make changes to your products, or enable a certain extension, Magento might start to rewrite all your URLs to include a suffix "-1" or some other number. Within the URL Rewrites, Magento differentiates between System URLs and Custom URLs. If the System URLs are broken like this, you should not fix this by adding new Custom URLs.
Instead, open up phpMyAdmin, create a backup of your Magento database, and flush the Magento table core_url_rewrite (so that it becomes totally empty). Immediately afterwards, refresh the Catalog Url Rewrites under Index Management. This will regenerate all System URLs.
you can edit url write,i think there will be entry like /shop-3.html just change it is you want
http://www.magentocommerce.com/wiki/modules_reference/english/mage_adminhtml/urlrewrite/index
and also refer
http://www.magentocommerce.com/knowledge-base/entry/what-url-rewrites-are-and-why-they-are-important
hope this will sure help you.
Simple answer
just delete url related to shop (custom and system generated), than run re-indexing it will work
And I don't want to use GET params.
Here are the details:
the user has a bunch of photos, and each photo must be shown by itself and have a unuique URL of the form
www.mysite.com/theuser/photoNumber-N
I create a unique URL for a user each time they add a new photo to their gallery
the web page that displays the user's photo is the same code for every user and every photo -- only the photo itself is different.
the user gives a URL to Person-A but then Person-A has one URL to that one photo and cannot see the user's other photos (because each photo has a unique URL and Person-A was given only one URL for one photo)
I want the following URLS to (somehow) end up loading only one web page with only the photo contents being different:
www.mysite/user-Terry/terryPhoto1
www.mysite/user-Terry/terryPhoto2
www.mysite/user-Jackie/JackiesWeddingPhoto
www.mysite/user-Jackie/JackiesDogPhoto
What I'm trying to avoid is this: having many copies of the same web page on my server, with the only difference being the .jpeg filename.
If I have 200 user and each has 10 photos -- and I fulfill my requirement that each photo is on a page by itself with a distinct URL -- right now I've got 2000 web pages, each displaying a unique photo, taking space on my web server and every page is identical and redundant disk-space-wasting HTML code, the only difference being the .JPEG file name of the photo to display.
Is there something I can do to avoid wasting diskspace and still meet my requirement that each photo has a unique URL?
Again I cannot use GET with parameters.
If you are on an Apache server, you can use Apache's mod_rewrite to accomplish just that. While the script you are writing will ultimately still be fetching GET variables (www.mysite.com/photos.php?id=photo-id), mod_rewrite will convert all the URL's served in the format you choose (www.mysite.com/user-name/photo-id).
Some ways you can implement it can be found here and here, while the actual documentation on the Apache module itself can be found here.
Go to IIS Manager. Go to the site hosted in IIS. Add additional binding for each url.
This will redirect all request the same location.
hey guys! why is it that everytime i click something on my website and try to go back one page, it says "Confirm Form Submission". Im running a local server. This is in contrast to other websites like facebook where i can go back a page without that annoying message asking me to refresh the page.
Nice Explanation indeed :
Because of the sloppy coding practices of web developers browsers were forced to add this message. the scenario is as follows:
1) user fills in form and submits (posts form)
2) the server process the post data and responds with a new page (confirm) marked as not cacheable
3) the user navigates to a new page.
4) the user press back:
for the the browser to display the page in step 2, because its marked no-cache, it must request it from the server, in other words do the repost of the data (do step 1). here is were the sloppy coding came in, if this was an credit card charge, and repost detection was not on the server, the card is charged twice. this was (is) so common a problem, that the browsers had to detect this and warn the users.
the best fix is in step two, the server sends a redirect to the confirm page. then when the user accesses the confirm via history or back, its a get request, not a post request and will not show the warning.
source : http://forums.asp.net/p/1553589/3814773.aspx
okay nevermind people. apparently i was using POST method everywhere. changing it to GET solves the problem. I think it has something to do with caching..
I usually don't use Smarty but am in the process of editing a prebuilt app, that uses Smarty for templating. It's super easy to check for the login status, but I have searched the Smarty site, docs and the app vendors docs and cannot find a tag of function to check for the initial user login. We need to pass a message to the user at their first login only.. and instead of writing it out I am hoping there is a tag we can use within Smarty, since it's already being used.
Thanks!
You can not do this by Smarty.
To differ the initial login from a later one, you have to store this information somewere. One aproach would be to use PHP and store it in the user database table (table "user", field "first_login").
The other one would be to store it in a cookie on the client side. But I wount suggest it, for you can not rely on it, as the user can turn of cookies.
So you need to find out, weather your application already stores this information in the user db table. Which it does most likely not. Therefore you need to define the db field and set it after login (using PHP). Afterwards you can user $smarty->assign() in your PHP code to publish your message to smarty in case of first login.