RSS Forums RSS
Please support our MySQL advertiser: Programming Forums
Views: 2172 | Replies: 38 | Solved
Reply
Join Date: Feb 2008
Posts: 312
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: display image from databse

  #11  
Apr 2nd, 2008
the type=file part 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
Reply With Quote  
Join Date: Feb 2008
Posts: 312
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: display image from databse

  #12  
Apr 2nd, 2008
no if the name file is changed then the browse button disappears. the reason for the images getting replaced must have something to do with how the mysql is displaying them.
Reply With Quote  
Join Date: Feb 2008
Posts: 312
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: display image from databse

  #13  
Apr 2nd, 2008
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

$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.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: display image from databse

  #14  
Apr 2nd, 2008
Originally Posted by kevin wood View Post
the type=file part 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*
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: display image from databse

  #15  
Apr 2nd, 2008
$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*
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: display image from databse

  #16  
Apr 2nd, 2008
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*
Reply With Quote  
Join Date: Feb 2008
Posts: 312
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: display image from databse

  #17  
Apr 2nd, 2008
Originally Posted by nav33n View Post
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.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: display image from databse

  #18  
Apr 2nd, 2008
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*
Reply With Quote  
Join Date: Feb 2008
Posts: 312
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: display image from databse

  #19  
Apr 2nd, 2008
should the where clause look something 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'].'"/>';
        }
Reply With Quote  
Join Date: Feb 2008
Posts: 312
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: display image from databse

  #20  
Apr 2nd, 2008
the changes made to the code on the last thread do not work it just keeps throwing up errors.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:28 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC