Please support our MySQL advertiser: Programming Forums
Views: 2172 | Replies: 38 | Solved
![]() |
the problem i am getting now is that on the other pages that i have just set up it is not storing anything to the mysql tables. i have created the tables on a new php page and set them to only create if they do not exist. then when i upload the images and go to the preview page nothing is being displayed.
the code i used to enter the data into the mysql tables looks like this
this is just a modified version of the code that works for the broadsheet upload. all that got changed was the variable names and the names of the table and the columns.
the code i used to see if the table was being populated looks like this
and it prints out the line there is nothing.
if the code works for the images_broad table why will this not work for the new tables that have been created.
because there is nothing stored in the table before this code was run should i use the insert into query so that the table gets populated at least once and then change it to update.
the reason i want it set to update is so that the server does not begin to get filled up with images after time.
the code i used to enter the data into the mysql tables looks like this
$tab1name="image/".$image_name; $tab1name2="image/thumbs/thumb_".$image_name; $copied = copy($_FILES['image']['tmp_name'], $tab1name); $copied = copy($_FILES['image']['tmp_name'], $tab1name2); $sql="UPDATE images_tab SET tab1='$tab1name2'"; $query = mysql_query($sql);
this is just a modified version of the code that works for the broadsheet upload. all that got changed was the variable names and the names of the table and the columns.
the code i used to see if the table was being populated looks like this
$query = "select * from images_tab";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0){
echo "There is something!"; //prints if there are more than 0 records
} else {
echo "There is nothing !"; // prints if there is nothing in the table
} and it prints out the line there is nothing.
if the code works for the images_broad table why will this not work for the new tables that have been created.
because there is nothing stored in the table before this code was run should i use the insert into query so that the table gets populated at least once and then change it to update.
the reason i want it set to update is so that the server does not begin to get filled up with images after time.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
•
•
•
•
thetype=filepart of the form does this not mean that this is a browse button i have not changed this yet but if i put [icode]type=file1[/code] would the file browse button still appear?
i will check and get back
No. Not that. <input type="file" name="uploadimage1"> This one.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
•
•
•
•
$sql="UPDATE images_tab SET tab1='$tab1name2'";
You are updating all the records to tab1name. Have a where clause and update only 1 record. Since you are updating all records, it shows the same image in the preview page.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
•
•
•
•
if the code works for the images_broad table why will this not work for the new tables that have been created.
because there is nothing stored in the table before this code was run should i use the insert into query so that the table gets populated at least once and then change it to update.
Exactly ! You have to insert a record to the table in order to update it. And again, dont update all the records, but only one record.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
•
•
You are updating all the records to tab1name. Have a where clause and update only 1 record. Since you are updating all records, it shows the same image in the preview page.
i have set my tables up so that each image that is uploaded has its own column. as it has its own column should it still need a where clause because there should only be one record in each column.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
When you upload a path, a new row is inserted and the "path" is stored in a column. But when you update the table(without a where clause), it updates all the rows and replace all the path values stored in the column with the new value. So, You should have a where clause while using update.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
should the where clause look something like this
if this line is correct it is effecting the preview page. when that page is accessed is says there is a problem with the mysql line
should the while be taken out and the line edited so it looks like this
all that section of code looks like this
$sql="UPDATE images_broad SET broad1='$broad1name2' WHERE broad1=`1`";
if this line is correct it is effecting the preview page. when that page is accessed is says there is a problem with the mysql line
while($row=mysql_fetch_array($result, MYSQL_ASSOC)){should the while be taken out and the line edited so it looks like this
$result=mysql_fetch_array($result, MYSQL_ASSOC)){all that section of code looks like this
$query = "SELECT * FROM images_broad";
$result=mysql_query($query);
$result=mysql_fetch_array($result, MYSQL_ASSOC)){
echo '<img src="'.$row['broad2'].'"/>';
}![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode