Jump to content

dennismonsewicz

Members
  • Posts

    1,136
  • Joined

  • Last visited

Everything posted by dennismonsewicz

  1. this is what i have: foreach($_FILES['uploadedfile']['name'] as $key) { if(!empty($key)) { $target_path = "uploads/" . $key . "<br />"; echo $target_path; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$key], $target_path)) { $att_qry = mysql_query("INSERT INTO uploads (upload_name, upload_path, project_name, project_id) VALUES ('$key', '$target_path', '$project_name', '" . $idresults->id . "')")or die(mysql_error()); } else { echo '<p>Don\'t work boss!</p>'; } } } And no each file needs to go in the same uploads folder
  2. change this $sql = "SELECT * FROM links WHERE 'id'='$id'"; to this $sql = "SELECT * FROM links WHERE id = '$id'";
  3. I am doing a multiple file upload and I was wondering how would the array breakdown for the $_FILES var as far as using the ['tmp_name'] goes? This is the code I am working with: foreach($_FILES['uploadedfile']['name'] as $key) { if(!empty($key)) { if(move_uploaded_file("uploads/" . $_FILES['uploadedfile']['tmp_name'], $target_path)) { $att_qry = mysql_query("INSERT INTO uploads (upload_name, upload_path, project_name, project_id) VALUES ('$key', '$target_path', '$project_name', '" . $idresults->id . "')")or die(mysql_error()); } } } How would does the ['tmp_name'] and the $key values match up when moving the file?
  4. ok i have adjusted my code: updated code: if(isset($_FILES['uploadedfile']['name'])) { foreach($_FILES['uploadedfile']['name'] as $key) { echo "uploads/" . $key . "<br />"; } } This code is adding an extra uploads/ and the end of the array... anyway of fixing this?
  5. I have this code: if(isset($_FILES['uploadedfile']['name'])) { foreach($_FILES['uploadedfile']['name'] as $key) { echo trim("uploads/" . $key, "uploads/"); } } The upload file input looks like this: echo '<label>Attach a file</label> <input type="file" name="uploadedfile[]" class="multi" />'; When I echo out the name of the file uploaded it is placing the string uploads/ at the end of the file... any ideas on how to fix this?
  6. ok so i have adjusted my code now: updated code: if(isset($_FILES['uploadedfile']['name'])) { foreach($_FILES['uploadedfile']['name'] as $key) { echo "uploads/" . $key; } } for some reason it is adding uploads/ at the end of the file... any ideas on how to fix this?
  7. do you want me to post the JS files? The first bit of code that i inserted is the only piece that asks for an uploaded file
  8. Here is the upload form: it's using jQuery to do a multiple file upload echo '<label>Attach a file</label> <input type="file" name="uploadedfile[]" class="multi" />'; The PHP code that isn't working: if(isset($_FILES['uploadedfile']['name'])) { foreach($_FILES['uploadedfile']['name'] as $key) { $upload_dir = "http://www.yoursitehere.com/uploads/"; $target_path = "uploads/"; $target_path = $target_path . basename($key); move_uploaded_file($_FILES[$key], $target_path); } $att_qry = mysql_query("INSERT INTO tbl_name (upload_name, upload_path, project_name, project_id) VALUES ('$key', '$target_path', '$project_name', '" . $idresults->id . "')")or die(mysql_error()); } Now the code is not grabbing the File name... any ideas on what I am doing wrong here?
  9. Is there a way to retrieve data from the affected row? Like if i wanted to retrieve the row id?
  10. How would I go about or could someone suggest a good tutorial on how to append an upload input to the page everytime a user wanted to upload more than one file?
  11. well it worked kinda... Its replacing everything thats a 1 or a 0 with an X... On the first two rows it adds x's all the way up to the PM column right after the Julie column Everyone after that adds x's all the up to the PM column after the Layne column and before the programming column Updated code: $val_qry = mysql_query("SELECT * FROM has_had_projects")or die(mysql_error()); // list vars to check $check_vars = array('pm1', 'designer1','pm2','writer','pm3','designer2','pm4','christine','pm5','designer3','pm6','julie', 'pm7','designer4','pm8','proofreading','pm9','layne','pm10','programming','pm11','testing'); while($row = mysql_fetch_array($val_qry)) { $id = $row['id']; $project = $row['project']; $project_id = $row['project_id']; // loop through variables to check. foreach($check_vars as $key ) { if(isset($row[$key]) && $row[$key] == 1) { $$key = 'X'; } } $arr = array($id, $project, $project_id, $pm1, $designer1, $pm2, $writer, $pm3, $designer2, $pm4, $christine, $pm5, $designer3, $pm6, $julie, $pm7, $designer4, $pm8, $proofreading, $pm9, $layne, $pm10, $programming, $pm11, $testing); $excel->writeLine($arr); }
  12. oh lol sorry about that... the $val var is supposed to be the $arr var... $excel->writeLine($val); The above code writes the line into the excel spreadsheet. So how would i use your code to change the values to X? and still append the data?
  13. two questions: 1. where are you declaring the $val var? 2. why did you use two $ on the $$key var?
  14. <?php $pm1 = $row['pm1']; $designer1 = $row['designer1']; $pm2 = $row['pm2']; $writer = $row['writer']; $pm3 = $row['pm3']; $designer2 = $row['designer2']; $pm4 = $row['pm4']; $christine = $row['christine']; $pm5 = $row['pm5']; $designer3 = $row['designer3']; $pm6 = $row['pm6']; $julie = $row['julie']; $pm7 = $row['pm7']; $designer4 = $row['designer4']; $pm8 = $row['pm8']; $proofreading = $row['proofreading']; $pm9 = $row['pm9']; $layne = $row['layne']; $pm10 = $row['pm10']; $programming = $row['programming']; $pm11 = $row['pm11']; $testing = $row['testing']; ?>
  15. How would i use the following code to check if a value in the DB equals to 1 and if so convert it to a string letter of X without having to write a bunch of if statements? <?php while($row = mysql_fetch_array($val_qry)) { $id = $row['id']; $project = $row['project']; $project_id = $row['project_id']; $pm1 = $row['pm1']; $designer1 = $row['designer1']; $pm2 = $row['pm2']; $writer = $row['writer']; $pm3 = $row['pm3']; $designer2 = $row['designer2']; $pm4 = $row['pm4']; $christine = $row['christine']; $pm5 = $row['pm5']; $designer3 = $row['designer3']; $pm6 = $row['pm6']; $julie = $row['julie']; $pm7 = $row['pm7']; $designer4 = $row['designer4']; $pm8 = $row['pm8']; $proofreading = $row['proofreading']; $pm9 = $row['pm9']; $layne = $row['layne']; $pm10 = $row['pm10']; $programming = $row['programming']; $pm11 = $row['pm11']; $testing = $row['testing']; $arr = array($id, $project, $project_id, $pm1, $designer1, $pm2, $writer, $pm3, $designer2, $pm4, $christine, $pm5, $designer3, $pm6, $julie, $pm7, $designer4, $pm8, $proofreading, $pm9, $layne, $pm10, $programming, $pm11, $testing); $excel->writeLine($val); } ?>
  16. its fixed! Working code: <?php function makeClickableLink($text) { $link = preg_replace('% ### Not preceded by an url start. (?<!url[=\]]) ( ### Protocol or start. (?: (??:https?|ftp)://) | www\. ) ### Body. (?> ### Gobble all non-space with the exception of [/url] (??!\[/url\])\S)+ ### Avoid ending punctuation. (?<!\p{P}) ) ### Not followed by an url end. (?!\[/url\]) ) %x', '<a href="$1">$1</a><br />', $text); return $link; } ?> Some how in my code all of the # symbols got replaced!
  17. This was working and now its not all of a sudden functions.php <?php function makeClickableLink($text) { $link = preg_replace('% Not preceded by an url start. (?<!url[=\]]) ( Protocol or start. (?: (??:https?|ftp)://) | www\. ) Body. (?> Gobble all non-space with the exception of [/url] (??!\[/url\])\S)+ Avoid ending punctuation. (?<!\p{P}) ) Not followed by an url end. (?!\[/url\]) ) %x', '<a href="$1" target="_blank">$1</a><br />', $text); return $link; } ?> Calling the function <?php makeClickableLink($results->comments) ?> This is not converting the links in the string to clickable links! and it was working...
  18. also you declared you class as class mysql and you are calling with new MySQL... I think these are case sensitive. I could be wrong but I think your classes are case sensitive... so if you created it with all lower case then you must call it using lower case.
×
×
  • 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.