Jump to content

msa025

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

msa025's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. bumping my topic to see if I can get any help...
  2. removed message. If anyone has any ideas about how to solve this problem, please let me know.
  3. I am currently trying to figure out a way to use button links instead of text links on several of my pages because of problems with the font color (and I think buttons are nifty). Anyway, I am essentially reading every user off of the database and reprinting it with a links to either edit or delete the user. I use the individual userID so that the edit_user.php and delete_user.php file know which user specifically to edit or delete. Anyway, I have tried different methods to use buttons, but none have worked. The closest I came was using hidden values, and passing it like you would a form...but it only keeps the last user information on the page. If anyone has any other ideas, I would greatly appreciate hearing them. <?php require_once('mysql_connect.php'); if((!isset($_SESSION['first_name'])) || (($_SESSION['user_type'] != 7) && ($_SESSION['user_type'] != 14) && ($_SESSION['user_type'] != 12))) { $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if((substr($url,-1) == '/') OR (substr($url,-1) == '\\')) { $url = substr($url,0,-1); } $url .= '/index.php'; ob_end_clean(); header("Location: $url"); exit(); } $display=20; if(isset($_GET['np'])) { $num_pages = $_GET['np']; } else { $query = "SELECT COUNT(*) FROM user ORDER BY lastName ASC"; $results = mysql_query($query); $row = mysql_fetch_array($results, MYSQL_NUM); $num_records = $row[0]; if ($num_records > $display) { $num_pages = ceil($num_records/$display); } else { $num_pages = 1; } } if (isset($_GET['s'])) { $start = $_GET['s']; } else { $start =0; } $link0 = "{$_SERVER['PHP_SELF']}?sort=una"; $link1 = "{$_SERVER['PHP_SELF']}?sort=fna"; $link2 = "{$_SERVER['PHP_SELF']}?sort=lna"; $link3 = "{$_SERVER['PHP_SELF']}?sort=ena"; $link4 = "{$_SERVER['PHP_SELF']}?sort=pna"; $link5 = "{$_SERVER['PHP_SELF']}?sort=tna"; if(isset($_GET['sort'])) { switch($_GET['sort']) { case 'lna': $order_by = 'lastName ASC'; $link2 = "{$_SERVER['PHP_SELF']}?sort=lnd"; break; case 'lnd': $order_by = 'lastName DESC'; $link2 = "{$_SERVER['PHP_SELF']}?sort=lna"; break; case 'fna': $order_by = 'firstName ASC'; $link1 = "{$_SERVER['PHP_SELF']}?sort=fnd"; break; case 'fnd': $order_by = 'firstName DESC'; $link1 = "{$_SERVER['PHP_SELF']}?sort=fna"; break; case 'una': $order_by = 'userID ASC'; $link0 = "{$_SERVER['PHP_SELF']}?sort=und"; break; case 'und': $order_by = 'userID DESC'; $link0 = "{$_SERVER['PHP_SELF']}?sort=una"; break; case 'ena': $order_by = 'email ASC'; $link3 = "{$_SERVER['PHP_SELF']}?sort=end"; break; case 'end': $order_by = 'email DESC'; $link3 = "{$_SERVER['PHP_SELF']}?sort=ena"; break; case 'tna': $order_by = 'types.typeName ASC'; $link5 = "{$_SERVER['PHP_SELF']}?sort=tnd"; break; case 'tnd': $order_by = 'types.typeName DESC'; $link5 = "{$_SERVER['PHP_SELF']}?sort=tna"; break; case 'pna': $order_by = 'phone ASC'; $link4 = "{$_SERVER['PHP_SELF']}?sort=pnd"; break; case 'pnd': $order_by = 'phone DESC'; $link4 = "{$_SERVER['PHP_SELF']}?sort=pna"; break; default: $order_by = 'lastName ASC'; break; } $sort = $_GET['sort']; } else { $order_by = 'lastName ASC'; $sort = 'rdd'; } $query = "SELECT userID, firstName, lastName, email, phone, types.typeName FROM user LEFT JOIN types ON user.userType=types.typeID ORDER BY $order_by LIMIT $start, $display"; $result = mysql_query($query); echo '<table align="center" cellspacing="0" cellpadding="5"> <tr> <td align="center"><b>Edit</b></td> <td align="center"><b>Delete</b></td> <td align="center"><b><a href="' . $link0 .'">User Name</a></b></td> <td align="center"><b><a href="' . $link1 .'">First Name</a></b></td> <td align="center"><b><a href="' . $link2 .'">Last Name</a></b></td> <td align="center"><b><a href="' . $link3 .'">Email</a></b></td> <td align="center"><b><a href="' . $link4 .'">Phone Number</a></b></td> <td align="center"><b><a href="' . $link5 .'">Position</a></b></td> </tr> '; $bg = '#eeeeee'; while($row = mysql_fetch_array($result, MYSQL_NUM)) { $bg =($bg=='#eeeeee' ?'#ffffff' : '#eeeeee'); echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="edit_user.php?id=' . $row['0']. '">Edit</a></td> <td align="left"><a href="delete_user.php?id=' . $row['0'] . '">Delete</a></td> <td align="left">' . $row['0'] . '</td> <td align="left">' . $row['1'] . '</td> <td align="left">' . $row['2'] . '</td> <td align="left">' . $row['3'] . '</td> <td align="left">' . $row['4'] . '</td> <td align="left">' . $row['5'] . '</td> </tr> '; } echo '</table>'; mysql_free_result($result); mysql_close(); if($num_pages > 1) { echo '<br /><p align="center">'; $current_page = ($start/$display)+1; if($current_page != 1) { echo '<a href="view_users.php?s=' . ($start - $display) . '&np=' . $num_pages . '&sort=' . $sort . '">Previous</a> '; } for($i = 1; $i <= $num_pages; $i++) { if($i != $current_page) { echo '<a href="view_users.php?s=' . (($display * ($i - 1 ))) . '&np=' . $num_pages . '&sort=' .$sort . '">' . $i . '</a> '; } } if($current_page != $num_pages) { echo '<a href="view_users.php?s=' . ($start + $display) . '&np=' . $num_pages . '&sort=' . $sort . '">Next</a>'; } echo '</p>'; } ?>
  4. I think I left it that way when I copied other code into this file. The other code needed to add the database entry first so it could name the file the same name as the uploadID. Is there any direct benefit to doing it the way you suggested as opposed to how I have implemented it? Or does it really not make much of a difference in the end?
  5. Checked that too...disk space is just fine. I can upload the file through dreamweaver or winscp with no problems, but I can't upload it via HTTP. I sent a copy of my code and my problem to my school's server admins (since it's not on my server), and I'm waiting to hear back from them in the event it's not something on their end. I was just hoping to have something to go with when I brought it up. Again, I'm pretty new at php and MySQL, so I wasn't sure if it was a problem with my code or what. And thanks for all the help so far. I really appreciate it.
  6. checked that. Permissions are at 777 for all upload folders. Again, it works at some times, but then it won't at other times.
  7. I'm not sure if it's a problem...but should you instead make the mysql_fetch_array call as follows: <code>$u = mysql_fetch_array($q, MYSQL_ASSOC)</code> As far as I'm aware, I think you need to send that value so it knows how to access the fields the way you are trying to...I could be wrong though.
  8. I checked into that...but my files are smaller than the MAX_FILE_SIZE. When I'm testing these functions out, I typically use the same 2-3 files. Those files worked yesterday morning and when I coded them up on friday afternoon, but they didn't last night. I also tried to change the MAX_FILE_SIZE last night just in case, but it didn't change any of the errors, so I put it back as it was. So, the MAX_FILE_SIZE, while small, shouldn't be what's causing the issue.
  9. Yea, I'm well aware of that page. The minute my code failed, I echoed the error number and searched php.net for it. None of the suggestions posted on that site have helped. Thank you for the reply however. Again, the problem seems to be intermittent. I'm just not overly sure why it would work for a while, and then not work for awhile...
  10. Hi everyone. I'm new to posting on these boards and relatively new to PHP. I am currently working on coding up a full site for my college radio station that I'm apart of. I'm trying to allow the djs to upload a picture of themselves and to allow the secretary to upload documents for download. All three functions were working just fine as of this morning, but now I keep getting error 7 when I use the move_uploaded_file. All of the permissions on the folder are set, and I didn't change the code from this morning to when the problem occurred, so I am unsure as to what is going on. The only other bit of information I have is the following: Array ( [upload] => Array ( [name] => t.jpg [type] => [tmp_name] => [error] => 7 => 0 ) ) and the php.ini settings areas follows: upload_max_filesize = 50M ;upload_tmp_dir= file_uploads=On The server is running FreeBSD. This is the university's MySQL server, so I am unable to change the php.ini file or any of the admin settings. I'm not sure if there is anything else I've left out...Anyways, here's the code as well. <?php if((!isset($_SESSION['first_name'])) || ($_SESSION['user_type'] < 3)) { $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if((substr($url,-1) == '/') OR (substr($url,-1) == '\\')) { $url = substr($url,0,-1); } $url .= '/index.php'; ob_end_clean(); header("Location: $url"); exit(); } if (isset($_GET['id'])) { $id= $_GET['id']; } elseif (isset($_POST['id'])) { $id=$_POST['id']; } else { echo '<h1 id = mainhead">Page Error</h1><p class="error">This page has been accessed in error.</p><p><br /><br/></p>'; exit(); } if(isset($_POST['submitted'])) { require_once('mysql_connect.php'); $allowed = array('.jpg','.jpeg','.bmp','.gif'); $filename = $_FILES['upload']['name']; // Get the name of the file (including file extension). print_r($_FILES); $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename. if(in_array($ext,$allowed)) { if(isset($_FILES['upload'])) { $query = "SELECT fileName FROM djpics WHERE uploadID = '$id'"; $result = mysql_query($query); if(!$result) { $query = "INSERT INTO djpics(uploadID, fileName, fileSize, fileType) VALUES ('$id', '{$_FILES['upload']['name']}','{$_FILES['upload']['size']}','{$_FILES['upload']['type']}')"; } else { $query = "UPDATE djpics SET fileName = '{$_FILES['upload']['name']}', fileSize = '{$_FILES['upload']['size']}', fileType = '{$_FILES['upload']['type']}' WHERE uploadID = '$id'"; } $result = mysql_query($query); if($result) { if(move_uploaded_file($_FILES['upload']['tmp_name'], "djpics/" . $id)) { echo '<p>The file has been uploaded.</p>'; } else { $query = "DELETE FROM djpics WHERE uploadID = $id"; $result = mysql_query($query); echo '<p><font color="red">The file could not be uploaded because.</font></p>'; switch($_FILES['upload']['error']) { case 1: print 'The file exceeds the upload_max_filesize setting.'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting.'; break; case 4: print 'The file was only partially uploade.'; break; case 6: print 'No temporary folder was available.'; break; default: print 'A system error occured.'; break; } } } else { echo '<p><font color="red">There was an error with the page.</font></p>'; } } else { echo '<p><font color="red">Your submission could not be processed due to a system error. We apologize for any inconvenience.</font></p>'; } } else { echo '<p><font color="red">The file must be either a .jpg, .jpeg, .gif, or .bmp!</font></p>'; } } ?> <form enctype="multipart/form-data" action="djpic.php" method="post"> <fieldset><legend>Upload a profile picture:</legend> <input type="hidden" name="MAX_FILE_SIZE" value="524288" /> <?php echo '<p><b>File:</b> <input type="file" name="upload" /></p><br /> </fieldset> <input type = "hidden" name="submitted" value="TRUE" /> <div align="center"><input type="submit" name="submit" value="Submit" /> <input type="hidden" name="id" value="' . $id . '"/></div> '; ?> </form> Anyways, please let me know if you have any ideas as to what I can do. I've been fighting with this all day, and I have completely run out of ideas on what could be wrong. Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.