I have created a image upload for the site i am working on i now want the uer to be able to click on a preview button and this takes them to a separate page where they can see the images that have been uploaded.
for this to happen would i have to send a query to the database to retrieve the information or can i simply display them using the variable name which was set for the images.
best way to store an image is to upload it. Store its directory as a varchar in a database then simply echo it back when you need it :D
there are better and more complicated but this is by far the easiest method
:D
i have now tried to connect to my database which is set up on the server and i keep getting could not connect. i have db.php page which sets up the database and recall this by using include db.php
Hi Kevin,
there's no way we could check the problem remotely.
Either you have the login data wrong (server name, username, password, db name) or the script doesn't connect or I don't know. Can you attach both db.php and the main script?
Hi Kevin,
you will have to change your db login data because now that you posted them here anyone can connect to your database and do whatever he wants.
I ran db.php and I got a valid connection.
To verify it I put this to see what was the mysql_pconnect() result.
var_dump($connection);
Because db.php already connects, you don't have to connect again in your main script. $connection will be available in the main script.
Frankly, you can just not use $connection at all - if you don't need more than one connection in your script.
You don't have to run mysql_select_db() each time before you use a database. It's enough to run it just once in db.php and it will stay selected. You only need to run mysql_select_db() again if you want to use a different database.
The error that you were looking for was $dbusername versus $dbuser - you define and use different variables. The proper solution is to remove the second connect attempt.
Also, you don't need to run mysql_close() at the script's end because you're using permanent connections mysql_pconnect() and they are not affected by mysql_close().