Forum Moderators: coopster
<?
$host = "host";
$user = "user";
$pass = "pass";
$dbname = "dbname";$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);$query= "select * from 4images_images where image_id='" . $_POST['image'] . "'";
$result= mysql_query($query);
// $num_results = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$filename=$row['image_media_file'];
$category=$row['cat_id'];$file="http://www.url.com"."/".$category."/".$filename;
header("Location:$file"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
Is it a problem with my redirection script? Do i have to use other redirection technique to get the file? thanks in advance.
i got that message when i try to browse the page with a Sony Ericsson T610. My guess is, if redirecting doesn't work this way, is it possible to use other method to redirect the user to the file? Probably prompt the user to save the file instead (will this work on a mobile phone?) I am so stuck :(
Btw, just wondering, if updating the database entry difficult? I already learnt how to access the information from mysql, but is it possible to update the data on the database once you've retrieved information from it? thanks!
1) access the information from database
2) use update to update the row (i only need to update a row)
but then where does DELETE & INSERT comes into then? do i have to delete the row first? then insert new data, then update? opss..i think i'm confused...i only want to inc + 1 to a field. But thanks to the link to the reference. It's really comprehensive!
a little list of commonly used mysql commands
So I installed MySQL, what now?
1. Create a database using CREATE DATABASE [mysql.com]
This gives you an empty DB, now what?
2. Create some tables using CREATE TABLE [mysql.com]. If you make a mistake try ALTER TABLE [mysql.com] or DROP TABLE [mysql.com] and make a new one.
(Designing the db is another lesson ;))
So a bunch of empty table in my DB, so what?
Well, the key to a Database is, yes you guessed it, data.
3. Manipulate some data
Get new data in the table
INSERT [mysql.com]
Need to change the data in the table
UPDATE [mysql.com]
Need to remove some data
DELETE [mysql.com]
Want to take a look at some data
SELECT [mysql.com]
These are all fairly standard functions though they can be very complex. Many more...
MySQL Online Manual [mysql.com]
I am a command line type but most people use phpmyadmin for these things and don't always understand right away how much is being done for them.
so from the manual,:
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name [, tbl_name ...]
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_definition]
This begins to get tougher. I wanted to change the data from 4images_image table, where Image_ID="blah blah" and change the Image_Hit= Image_Hit + 1
so i use this command:
UPDATE 4images_Images SET 4images_Hit=4Images_Hit + 1 WHERE Image_ID="Blah blah";
Am i right guys? Am i right? :)This is actually very interesting. It's kind of nice if you can get it to work. Thank you jatar, you are my man!