By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,538 Members | 2,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,538 IT Pros & Developers. It's quick & easy.

Photo upload problem

P: 9
I am a noobie so pleas bear with me..

I am trying to link a image to a MYSQL variable.

I have user photos that i would like to link this page. So far I created an image upload and renamed the imaged to the username.jpg. Figured it would be easy to then link but nothing seems to be working.


Here is the total code..

Expand|Select|Wrap|Line Numbers
  1. <?php require_once('../Connections/JMI10.php'); ?><?php require_once('../Connections/JMI10.php'); ?><?php require_once('../Connections/JMI10.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. if (!function_exists("GetSQLValueString")) {
  35. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  36. {
  37.   if (PHP_VERSION < 6) {
  38.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  39.   }
  40.  
  41.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  42.  
  43.   switch ($theType) {
  44.     case "text":
  45.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  46.       break;    
  47.     case "long":
  48.     case "int":
  49.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  50.       break;
  51.     case "double":
  52.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  53.       break;
  54.     case "date":
  55.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  56.       break;
  57.     case "defined":
  58.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  59.       break;
  60.   }
  61.   return $theValue;
  62. }
  63. }
  64.  
  65. if (!function_exists("GetSQLValueString")) {
  66. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  67. {
  68.   if (PHP_VERSION < 6) {
  69.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  70.   }
  71.  
  72.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  73.  
  74.   switch ($theType) {
  75.     case "text":
  76.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  77.       break;    
  78.     case "long":
  79.     case "int":
  80.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  81.       break;
  82.     case "double":
  83.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  84.       break;
  85.     case "date":
  86.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  87.       break;
  88.     case "defined":
  89.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  90.       break;
  91.   }
  92.   return $theValue;
  93. }
  94. }
  95.  
  96. $editFormAction = $_SERVER['PHP_SELF'];
  97. if (isset($_SERVER['QUERY_STRING'])) {
  98.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  99. }
  100.  
  101. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "useredit")) {
  102.   $updateSQL = sprintf("UPDATE ``user`` SET username=%s WHERE userid=%s",
  103.                        GetSQLValueString($_POST['username'], "text"),
  104.                        GetSQLValueString($_POST['userid'], "text"));
  105.  
  106.   mysql_select_db($database_JMI10, $JMI10);
  107.   $Result1 = mysql_query($updateSQL, $JMI10) or die(mysql_error());
  108.  
  109.   $updateGoTo = "master.php";
  110.   if (isset($_SERVER['QUERY_STRING'])) {
  111.     $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
  112.     $updateGoTo .= $_SERVER['QUERY_STRING'];
  113.   }
  114.   header(sprintf("Location: %s", $updateGoTo));
  115. }
  116.  
  117. mysql_select_db($database_JMI10, $JMI10);
  118. $query_rsshowuser = "SELECT * FROM `user`";
  119. $rsshowuser = mysql_query($query_rsshowuser, $JMI10) or die(mysql_error());
  120. $row_rsshowuser = mysql_fetch_assoc($rsshowuser);
  121. $totalRows_rsshowuser = mysql_num_rows($rsshowuser);
  122.  
  123. $maxRows_DetailRS1 = 10;
  124. $pageNum_DetailRS1 = 0;
  125. if (isset($_GET['pageNum_DetailRS1'])) {
  126.   $pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
  127. }
  128. $startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1;
  129.  
  130. $colname_DetailRS1 = "-1";
  131. if (isset($_GET['recordID'])) {
  132.   $colname_DetailRS1 = $_GET['recordID'];
  133. }
  134. mysql_select_db($database_JMI10, $JMI10);
  135. $query_DetailRS1 = sprintf("SELECT * FROM survey1 WHERE userid = %s", GetSQLValueString($colname_DetailRS1, "int"));
  136. $query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
  137. $DetailRS1 = mysql_query($query_limit_DetailRS1, $JMI10) or die(mysql_error());
  138. $row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
  139.  
  140. if (isset($_GET['totalRows_DetailRS1'])) {
  141.   $totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
  142. } else {
  143.   $all_DetailRS1 = mysql_query($query_DetailRS1);
  144.   $totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
  145. }
  146. $totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
  147.  
  148. $maxRows_DetailRS2 = 50;
  149. $pageNum_DetailRS2 = 0;
  150. if (isset($_GET['pageNum_DetailRS2'])) {
  151.   $pageNum_DetailRS2 = $_GET['pageNum_DetailRS2'];
  152. }
  153. $startRow_DetailRS2 = $pageNum_DetailRS2 * $maxRows_DetailRS2;
  154.  
  155. $colname_DetailRS2 = "-1";
  156. if (isset($_GET['recordID'])) {
  157.   $colname_DetailRS2 = $_GET['recordID'];
  158. }
  159. mysql_select_db($database_JMI10, $JMI10);
  160. $query_DetailRS2 = sprintf("SELECT * FROM `user` WHERE userid = %s ORDER BY `state` ASC", GetSQLValueString($colname_DetailRS2, "-1"));
  161. $query_limit_DetailRS2 = sprintf("%s LIMIT %d, %d", $query_DetailRS2, $startRow_DetailRS2, $maxRows_DetailRS2);
  162. $DetailRS2 = mysql_query($query_limit_DetailRS2, $JMI10) or die(mysql_error());
  163. $row_DetailRS2 = mysql_fetch_assoc($DetailRS2);
  164.  
  165. if (isset($_GET['totalRows_DetailRS2'])) {
  166.   $totalRows_DetailRS2 = $_GET['totalRows_DetailRS2'];
  167. } else {
  168.   $all_DetailRS2 = mysql_query($query_DetailRS2);
  169.   $totalRows_DetailRS2 = mysql_num_rows($all_DetailRS2);
  170. }
  171. $totalPages_DetailRS2 = ceil($totalRows_DetailRS2/$maxRows_DetailRS2)-1;
  172. ?>
  173. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  174. <html xmlns="http://www.w3.org/1999/xhtml">
  175. <head>
  176. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  177. <title>Untitled Document</title>
  178. <style type="text/css">
  179. <!--
  180. .kk {
  181.     color: #030303;
  182. }
  183. .style1 {color: #F00; font-weight: bold; }
  184. .ee {
  185.     color: #030303;
  186. }
  187. .ee1 {
  188.     color: #FFF;
  189. }
  190. .dd {color: #F00;
  191. }
  192. .dd {
  193.     font-size: 12px;
  194.     color: #FFF;
  195. }
  196. .ee2 {color: #030303;
  197. }
  198. .hh {
  199.     text-align: left;
  200.     font-weight: bold;
  201. }
  202. .jj {
  203.     color: #FFF;
  204.     text-align: center;
  205.     font-weight: bold;
  206. }
  207. .kk {
  208.     text-align: left;
  209. }
  210. .jj .jj {
  211.     font-weight: bold;
  212. }
  213. .jj {
  214.     font-weight: bold;
  215. }
  216. .jj {
  217.     text-align: left;
  218. }
  219. .ll {
  220.     font-weight: bold;
  221. }
  222. .kk {
  223.     font-weight: bold;
  224.     color: #030303;
  225. }
  226. .oo {
  227.     font-weight: bold;
  228.     font-size: 16px;
  229. }
  230. .hh {
  231.     text-align: left;
  232. }
  233. .ll {
  234.     font-family: Arial, Helvetica, sans-serif;
  235. }
  236. -->
  237. </style>
  238. </head>
  239.  
  240. <body>
  241. <table width="701" border="0">
  242.   <tr>
  243.     <th width="532" valign="top" class="hh" scope="col"><p><span class="style1">Inspector Detail Page</span><span class="kk"></span></p>
  244.       <p><a href="master.php">Inspector List</a> <a href="list.php">Admin Menu</a></p>
  245.     <p class="ll"><?php echo $row_DetailRS2['firstname']; ?> <?php echo $row_DetailRS2['middlename']; ?> <?php echo $row_DetailRS2['lastname']; ?></p>
  246.     <table width="453" height="58" border="1">
  247.       <tr>
  248.         <th width="82" bgcolor="#000080" class="jj" scope="col"><span class="kk" style="color: #FFF">Userid</span></th>
  249.         <th width="144" class="hh" scope="col"><?php echo $row_DetailRS2['userid']; ?></th>
  250.         <th width="76" bgcolor="#000080" class="jj" scope="col">Username </th>
  251.         <th width="163" class="hh" scope="col"><?php echo $row_DetailRS2['username']; ?></th>
  252.       </tr>
  253.       <tr>
  254.         <td bgcolor="#000080" class="jj">Status</td>
  255.         <td class="hh"><?php echo $row_DetailRS2['usertype']; ?></td>
  256.         <td bgcolor="#000080" class="jj">Password</td>
  257.         <td class="hh"><?php echo $row_DetailRS2['password']; ?></td>
  258.       </tr>
  259.     </table></th>
  260.     <th width="153" align="left" valign="middle" scope="col"><img src="http://bytes.com/topic/php/idphoto/nclark.jpg" width="157" height="232" /></th>
  261.   </tr>
  262. </table>
  263. <table border="1" align="left">
  264.   <tr>
  265.     <td width="292" bgcolor="#DBDBDB" class="kk">Address1</td>
  266.     <td width="338"><?php echo $row_DetailRS2['address1']; ?></td>
  267.   </tr>
  268.   <tr>
  269.     <td bgcolor="#DBDBDB" class="kk">Address2</td>
  270.     <td><?php echo $row_DetailRS2['address2']; ?></td>
  271.   </tr>
  272.   <tr>
  273.     <td bgcolor="#DBDBDB" class="kk">City</td>
  274.     <td><?php echo $row_DetailRS2['city']; ?></td>
  275.   </tr>
  276.   <tr>
  277.     <td bgcolor="#DBDBDB" class="kk">County</td>
  278.     <td><?php echo $row_DetailRS2['county']; ?></td>
  279.   </tr>
  280.   <tr>
  281.     <td bgcolor="#DBDBDB" class="kk">State</td>
  282.     <td><?php echo $row_DetailRS2['state']; ?></td>
  283.   </tr>
  284.   <tr>
  285.     <td bgcolor="#DBDBDB" class="kk">Zipcode</td>
  286.     <td><?php echo $row_DetailRS2['zipcode']; ?></td>
  287.   </tr>
  288.   <tr>
  289.     <td bgcolor="#DBDBDB" class="kk">Cell Phone</td>
  290.     <td><?php echo $row_DetailRS2['cellphone']; ?></td>
  291.   </tr>
  292.   <tr>
  293.     <td bgcolor="#DBDBDB" class="kk">Home Phone</td>
  294.     <td><?php echo $row_DetailRS2['homephone']; ?></td>
  295.   </tr>
  296.   <tr>
  297.     <td bgcolor="#DBDBDB" class="kk">Email Address</td>
  298.     <td><?php echo $row_DetailRS2['email']; ?></td>
  299.   </tr>
  300.   <tr>
  301.     <td bgcolor="#DBDBDB" class="kk">Home Territory</td>
  302.     <td><?php echo $row_DetailRS2['hometerritory']; ?></td>
  303.   </tr>
  304.   <tr>
  305.     <td bgcolor="#DBDBDB" class="kk">Remote Territory</td>
  306.     <td><?php echo $row_DetailRS2['remoteterritory']; ?></td>
  307.   </tr>
  308.   <tr>
  309.     <td bgcolor="#DBDBDB" class="kk">Previous Experience PErforming Inspections?</td>
  310.     <td><?php echo $row_DetailRS2['experience']; ?></td>
  311.   </tr>
  312.   <tr>
  313.     <td bgcolor="#DBDBDB" class="kk">DIgital Camera Type:</td>
  314.     <td><?php echo $row_DetailRS2['camera']; ?></td>
  315.   </tr>
  316.   <tr>
  317.     <td bgcolor="#DBDBDB" class="kk">List Experience</td>
  318.     <td><?php echo $row_DetailRS2['experience2']; ?></td>
  319.   </tr>
  320.   <tr>
  321.     <td bgcolor="#DBDBDB" class="kk"><span class="ee1" style="color: #030303">How many days are you willing to work per week?</span></td>
  322.     <td><?php echo $row_DetailRS2['numberofdays']; ?></td>
  323.   </tr>
  324.   <tr>
  325.     <td bgcolor="#DBDBDB" class="kk">Are you currently working full time?</td>
  326.     <td><?php echo $row_DetailRS2['fulltime']; ?></td>
  327.   </tr>
  328.   <tr>
  329.     <td bgcolor="#DBDBDB" class="kk">Are you available to work DAYTIME hours? </td>
  330.     <td><?php echo $row_DetailRS2['daytime']; ?></td>
  331.   </tr>
  332.   <tr>
  333.     <td bgcolor="#DBDBDB" class="kk">Internet Speed</td>
  334.     <td><?php echo $row_DetailRS2['intenet']; ?></td>
  335.   </tr>
  336.   <tr>
  337.     <td bgcolor="#DBDBDB" class="kk">Would You Be Willing To Obtain High Speed Internet?</td>
  338.     <td><?php echo $row_DetailRS2['internet2']; ?></td>
  339.   </tr>
  340.   <tr>
  341.     <td bgcolor="#DBDBDB" class="kk">Preffered Browser</td>
  342.     <td><?php echo $row_DetailRS2['browser']; ?></td>
  343.   </tr>
  344.   <tr>
  345.     <td bgcolor="#DBDBDB" class="kk">Operating System</td>
  346.     <td><?php echo $row_DetailRS2['operatingsystem']; ?></td>
  347.   </tr>
  348.   <tr>
  349.     <td bgcolor="#DBDBDB" class="kk"><span class="ee">How do you rate your computer knowledge?</span></td>
  350.     <td><?php echo $row_DetailRS2['techknowledge']; ?></td>
  351.   </tr>
  352.   <tr>
  353.     <td bgcolor="#DBDBDB" class="kk">How many years have you been using a computer?</td>
  354.     <td><?php echo $row_DetailRS2['techyears']; ?></td>
  355.   </tr>
  356.   <tr>
  357.     <td bgcolor="#DBDBDB" class="kk">A &quot;URL&quot; refers to which of the following</td>
  358.     <td><?php echo $row_DetailRS2['techurl']; ?></td>
  359.   </tr>
  360.   <tr>
  361.     <td bgcolor="#DBDBDB" class="kk">When navigating a website, <br />
  362. what would you do to return to the last page viewed?</td>
  363.     <td><?php echo $row_DetailRS2['technav']; ?></td>
  364.   </tr>
  365.   <tr>
  366.     <td bgcolor="#DBDBDB" class="kk">Photo resolution refers to what?</td>
  367.     <td><?php echo $row_DetailRS2['techcamres']; ?></td>
  368.   </tr>
  369.   <tr>
  370.     <td bgcolor="#DBDBDB" class="kk">The right button on the mouse <br />
  371. is used for the following tasks?</td>
  372.     <td><?php echo $row_DetailRS2['techmouse']; ?></td>
  373.   </tr>
  374.   <tr>
  375.     <td bgcolor="#DBDBDB" class="kk">Drivers License</td>
  376.     <td><?php echo $row_DetailRS2['dl']; ?></td>
  377.   </tr>
  378.   <tr>
  379.     <td bgcolor="#DBDBDB" class="kk">Accepted IC Agreement?</td>
  380.     <td><?php echo $row_DetailRS2['icaccept']; ?></td>
  381.   </tr>
  382.   <tr>
  383.     <td bgcolor="#DBDBDB" class="kk">Social Security Number</td>
  384.     <td><?php echo $row_DetailRS2['ssnumber']; ?></td>
  385.   </tr>
  386.   <tr>
  387.     <td bgcolor="#DBDBDB" class="kk">Birth Date</td>
  388.     <td><?php echo $row_DetailRS2['birthdate']; ?></td>
  389.   </tr>
  390. </table>
  391.  
  392.  
  393. </body>
  394. </html>
  395. <?php
  396. mysql_free_result($rsshowuser);
  397.  
  398. mysql_free_result($DetailRS1);
  399.  
  400. mysql_free_result($DetailRS2);
  401. ?>
May 28 '09 #1
Share this Question
Share on Google+
1 Reply


prabirchoudhury
100+
P: 162
hey

1. next time wrap your code inside the "code wraper" # button right top of the edit box. your thread heading "photo upload problem" but there is nothing abt upload i could see in your code.


2. what part of your code having problem ? please mention specificly. you dont have much comments in your code as well.


3. make sure that your image directory is right and image exist there.


mention the specificly where you are having problem ...
May 29 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.