PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 4th, 2000, 08:48 PM
cbernaut cbernaut is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 3 cbernaut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello all,

I'm having a problem inserting photos into my MySQL database.

I have the following form to submit the photos:

===============

<form method="post" action="insertar_casa.php3" enctype="multipart/form-data">
<input type="text" name="text_foto[]" size="25" maxlength="25">
<input type="file" name="foto[]">
<input type="text" name="text_foto[]" size="25" maxlength="25">
<input type="file" name="foto[]">
<input type="text" name="text_foto[]" size="25" maxlength="25">
<input type="file" name="foto[]">
<input type="text" name="text_foto[]" size="25" maxlength="25">
<input type="file" name="foto[]">
<input type="submit" name="Submit" value="Ingresar Datos">
</form>

===============

I'm using the following code for the php processing file "insertar_casa.php3":

===========================================================
<?php

/* Set database variables */

$dbName = "mydatabase";
$pass = "mypassword";

/* Get the amount of photos submitted */

$foto_cuantity = 0;

for ($j=0; $j < 12; $j++) {

if ($foto_size[$j] != 0){
$foto_cuantity++;
print "The name of file number $j is $foto_name[$j].<p>";
}
}

print "The amount of photos you submitted is $foto_cuantity.<p>";

/* Insert each photo and corresponding text into the MySQL Database */

for ($i=0; $i < $foto_cuantity; $i++) {

$PSize = $foto_size[$i];
$mysqlphoto = addslashes(fread(fopen($foto[$i], "r"), $PSize));
mysql_connect("localhost","$dbName","$pass") or die("Unable to connect to MySQL server");
@mysql_select_db($dbName) or die("Unable to select database");
mysql_query("INSERT INTO imagenes (prop_num,titulo,file) VALUES($prop_num,'$text_foto[$i]',$mysqlphoto)");
}
?>

===================================================

But I always get the output "The amount of photos you submitted is O."

Does anyone have any idea why the second script doesn't recognize the uploaded files?

I'm pulling out my already spare amount of hair over this one. Can anybody see any mistakes I've made?

Thanks a million!
Bryan

------------------

Reply With Quote
  #2  
Old June 5th, 2000, 10:36 AM
mavenman mavenman is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 4 mavenman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to mavenman
One problem that I see with your transfer of the variables is that you are using the variables of $text_foto[] and $foto[] in the first form but then you use $foto_size[] and $foto_name[] without designating those variables from the data from the previous form. Your second page looks correct other than the fact that variables that it is using do not have values for them so the answer would be correct that the amount of photos is "0".

You need to call $text_foto[] and $foto[] in the second page and format them into $foto_size[] and $foto_name[] for use later in the page.

Hope this helps,

Maven

[This message has been edited by mavenman (edited June 05, 2000).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Uploading images to MySQL

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap