Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

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 Codewalkers Forums Sponsor:
  #1  
Old May 28th, 2003, 08:47 PM
Bard09 Bard09 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 18 Bard09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Not posting to MySQL database...

Hum. I've been messing around with my data submitting code trying implement an image upload, and now I've done tangled up my code. The form loads up, and I recieve my Echo stating that I've posted the form data with the image to the database, but nothing is actually posted. I'm pretty sure the problem is in my PHP code somewhere. Can anyone help me out? Keep in mind I'm still relatively new at all of this! Thanks...

(I've edited my posted code a few times. It's just the image submitting I'm having trouble with, now)

php Code:
Original - php Code
  1. <?php
  2. if(isset($_POST['submit']))
  3. {
  4. $db = mysql_connect(xxxxxxxxxxxxxx) OR DIE (mysql_error());
  5. mysql_select_db("Honor_Bios",$db) OR DIE (mysql_error());
  6.  
  7. $first_name=$_POST[first_name];
  8. $last_name=$_POST[last_name];
  9. $hometown=$_POST[hometown];
  10. $age=$_POST[age];
  11. $major=$_POST[major];
  12. $anything=$_POST[anything];
  13. $id=$_POST[id];
  14.  
  15. $image_types = Array ("image/bmp",
  16.                         "image/jpeg",
  17.                         "image/pjpeg",
  18.                         "image/gif",
  19.                         "image/x-png");
  20.  
  21.   $userfile  = addslashes (fread (fopen ($_FILES["userfile"]["tmp_name"], "r"), filesize ($_FILES["userfile"]["tmp_name"])));
  22.   $file_name = $_FILES["userfile"]["name"];
  23.   $file_size = $_FILES["userfile"]["size"];
  24.   $file_type = $_FILES["userfile"]["type"];
  25.  
  26.   if (in_array (strtolower ($file_type), $image_types)) {
  27.     $sql = "INSERT INTO Freshmen (first_name,last_name,hometown,age,major,anything,  image_name,image_type,image_size,image_date) ";
  28.     $sql.= "VALUES (";
  29.     $sql.= "'{$first_name}', '{$last_name}', '{$hometown}', '{$age}', '{$major}', '{$anything}', '{$file_type}', '{$userfile}', '{$file_size}', '{$file_name}', NOW())";
  30.     @mysql_query ($sql, $db);
  31.     Header("Location:".$_SERVER["PHP_SELF"]);
  32.     echo "Thank you! Information entered with picture.n";
  33.     exit();
  34. }
  35. else
  36. {
  37. $db = mysql_connect(xxxxxxxxxxxxxxxxxxxx);
  38. mysql_select_db("Honor_Bios",$db);
  39. $sql = "INSERT INTO Freshmen (first_name,last_name,hometown,age,major,anything)   VALUES ('$first_name', '$last_name', '$hometown', '$age', '$major', '$anything')";
  40. $result = mysql_query($sql);
  41. echo "Thank you! Information entered without picture.n";
  42. }
  43. }
  44. else
  45. {
  46. ?>
  47. <form method="post" action="<?php echo $PHP_SELF?>" enctype="multipart/form-data">
  48. First name:<input type="Text" name="first_name"><br>
  49. Last name:<input type="Text" name="last_name"><br>
  50. Hometown:<input type="Text" name="hometown"><br>
  51. Age:<input type="Text" name="age"><br>
  52. Major:<input type="Text" name="major"><br>
  53. Anything? <input type="Text" name="anything"><br>
  54. Image of yourself II <input type="file" name="userfile"  size="40"><br>
  55. <input type="Submit" name="submit" value=" Enter information"></form>
  56. <?php
  57. }
  58. ?>


Thanks again...

Signed,

Weary in Washington!

Reply With Quote
  #2  
Old May 30th, 2003, 07:30 PM
opus006 opus006 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 65 opus006 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Not posting to MySQL database...

echo your $sql line to make sure it is correct
echo $sql;
$result = myslq_query($sql);
if ($result)
echo mysql_affedted_rows()." added correctly";

Do you use datatype Blob for $userfile?



Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Not posting to MySQL database...


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway