Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. You wouldn't store the 'song' in the database. You'd store the path or link to it. When you add a new title/artist, etc. do you complete a form to do that? If so, you could add a file upload field to it for the mp3's and insert the name into the mysql database at the same time.
  2. Yeah, I think the error message is petering out before it displays the part about the array. No need for that part of the code as well as the extra comma.
  3. ? 's are a protected character. Instead of using it as a placeholder try using just single quotes for each. (' ', ' ', ' ', ' ', ' ')
  4. Grrr... ok, this code controls the form validation and mysql insertion/validation/check. What's happening is when I click on the menu item 'Add Picks' which is this page/form it's automatically submitting the form instead of waiting for it to be completed. Therefore, it's inserting blank fields into the database with the exception of the date. I can't spot where i'm missing the right sequence to stop this from happening: <? $v_sbm=$_REQUEST['submit']; $connection = mysql_connect($dbhost, $dbusername, $dbpass); $SelectedDB = mysql_select_db($dbname); // set our POST variables $step1 = mysql_real_escape_string($_POST['step1']); $step2 = mysql_real_escape_string($_POST['step2']); $step3 = mysql_real_escape_string($_POST['step3']); $step4 = mysql_real_escape_string($_POST['step4']); $date = date("m/d/Y"); $err = ""; $err_dupe = ""; // validate data if (isset($v_sbm)) { if(trim($step1)== "") { $err .="Step One cannot be blank.<br>"; } if(trim($step2)== "") { $err .="Step Two cannot be blank.<br>"; } if(trim($step3) == "") { $err .="Step Three cannot be blank.<br>"; } if(trim($step4) == "") { $err .="Step Four cannot be blank.<br>"; } } if (empty($err)){ $dupe = "SELECT * FROM picks WHERE date='$date'"; $dupe_results = mysql_query($dupe) or die(mysql_error()); $num_rows = mysql_num_rows($dupe_results); if ($num_rows >= 1) { $err_dupe .="There are already picks entered for this date: $date . If you wish to edit them then select Display Picks and choose the date you wish to edit.<br>\n"; } else { if (empty($err_dupe)){ $sql = "INSERT INTO picks (step1, step2, step3, step4, date) VALUES ( '$step1', '$step2', '$step3', '$step4', '$date')"; $results = mysql_query($sql) or die(mysql_error()); } } } ?> To recap, in my 'admin' area there's several links and the one pointing to this one is Add Picks (points to picks_add.php which this code is part of). Immediately upon displaying the page it also displays the echoed results (parsed from this code inserted into the body of the form) <? if(!$results) { echo "Could not enter new picks into database. Please re-enter.<br>\n"; } else { echo "<font color='#0000FF'>New picks successfully entered for $date.<br>\n"; echo "<ul><li>Step 1: $step1</li>\n <li>Step 2: $step2</li>\n <li>Step 3: $step3</li>\n <li>Step 4: $step4</li>\n </ul><br>\n"; } ?> None of this should happen until the Submit button is pressed
  5. Never mind on that! I found it like 10 seconds after I posted. I had (!results) when it should be (!$results).
  6. That did the trick! Just for my edification, why wouldn't the == work as opposed to the >= ? And, this may be related to my lack of expertise as well, but this isn't functioning as it logically should. <? if(!results ) { echo "Could not enter new picks into database. Please re-enter.<br>\n"; } else { echo "<font color='#0000FF'>New picks successfully entered for $date.<br>\n"; echo "<ul><li>Step 1: $step1</li>\n <li>Step 2: $step2</li>\n <li>Step 3: $step3</li>\n <li>Step 4: $step4</li>\n </ul><br>\n"; } ?> It's displaying the <ul> stuff whether or not the query for inserting it was successful.
  7. I don't get any errors and i'm using a varchar format for the field instead of the mysql 'date' format. That's what I can't understand is why it's bypassing the validation without an error and simply running the 2nd query. There may be something else I have to validate against but there's nothing 'unique' except an id that's auto-incremented for each entry. But, that's also based upon the date as well as each day should be one entry. Therefore one id per day.
  8. Ok, i'm trying to prevent certain information being inserted more than once into a mysql database. I'm using this code to validate against the 'date' field. If there's no entry then it runs the $sql INSERT: <? if ($err == "") { $dupe = "SELECT * FROM picks WHERE date='$date'"; $dupe_results = mysql_query($dupe) or die(mysql_error()); $num_rows = mysql_num_rows($dupe_results); if ($num_rows == 1) { echo "There are already picks entered for this date: $date . If you wish to edit them then select Display Picks and choose the date you wish to edit.<br>\n"; } else { $sql = "INSERT INTO picks (step1, step2, step3, step4, date) VALUES ( '$step1', '$step2', '$step3', '$step4', '$date')"; $results = mysql_query($sql) or die(mysql_error()); } } ?> Problem is it's not working. I have the $date variable set like this: $date = date("m/d/Y"); Which returns todays date. Maybe i'm missing something but it appears that it either won't validate against that date format ( 01/31/2007 ) or my code is wrong.
  9. Thanks for the heads up, Chronister. Jesirose and I have indeed exchanged PM's before. However, it's not appearing to go through to her. Not sure why. I'm 100% certain, though, that it wasn't something belligerent or against the rules :)  We discussed some work.
  10. Jesirose, i've been trying to PM you but not sure if the system is working or if you're getting them. Contact me, please.
  11. Thanks for that tip, Orio. But let me ask you a question. The fact that the file is already inside an .htaccess protected 'members-only' folder, wouldn't that prohibit anyone from directly accessing it?
  12. Well, you'd have to run a query first to determine what's there. Something like: [code] $sql = "SELECT * FROM tablename WHERE hello='hello' "; $results = mysql_query($sql) or die(mysql_error()); if (!results) { echo "nothing matches that entry"; } else { echo $results; [/code]
  13. Orio, i'm assuming with that extended code that it's also protecting the actual location of the file?
  14. Thanks, Tarun, but I don't need a complete download system. It's one file in a protected directory. :) corbin, I see this header reference that looks like the one: header('Content-type: application/pdf'); Which, according to the manual text, forces the download.
  15. I want to provide a downloadable PDF file but the typical link to it simply opens it in a window. I want to force that file to be downloaded without having to ZIP it. Do I need to write a script to do this? If so, insight or ideas?
  16. Yep, you can do something like this: $newid = mysql_insert_id();
  17. Maybe I don't quite get where your problem is...but since you're using the SELECT * FROM query that summons everything from that table into an array. Therefore you can use that data in a couple ways like perhaps a while loop.
  18. Ok, then the function setup that Deltran specified would work perfectly as it does what you've outlined. It continues to execute code after the original script has finished. Check out the link he provided for full details on it.
  19. Option #3! Thanks Deltran. :) How it would work would be dependent upon how you handle the data. For example, if your uploaded.php script writes info to a MySQL database then this secondary function would need to access it if you want to transfer some of that data to another location.
  20. Hmmm...ok, here's the problem. A script can't execute unless it's told to execute. That's exactly what cron does...tells things to execute at specific times. Otherwise i'm not aware of any magical solution that allows scripts to operate on their own. As far as I can see you have the two choices. Run a cron as often as you wish or have a sub-script run simultaneously with your main script that updates the data you're seeking.
  21. Ok, so you don't want it to run each time someone accesses the uploaded.php script. Even if you're going to use 'cron' then you'll need to have something that executes each time someone accesses the uploaded.php file that writes the data you need into a text file or database, for example, that would contain the necessary details you need for your update parameters like user_id, etc. Then, set up a cron to run something like update_cron.php that runs the queries you need by accessing that text file (or database tables).
  22. http://www.phpfreaks.com/forums/index.php/topic,37442.0.html
  23. Looks good to me. But i'm not sure if that's really guarding against anything. I'm assuming if they used something other than digits they'd get a 404 error. Or, a page id that doesn't exist would do the same. Might be wise to include some custom 404 page as another deterrent as well as protection against them looking for an open directory (no index.xxx page). Someone else asked a similar question in how to make sure the $_GET was populated by an actual URL passing it. You might search a bit in this forum for that topic.
  24. Easiest way is to write a function, save it in your 'other' file and then 'include' that file into your uploaded.php script and call the function. That way when the uploaded.php script executes it will also execute the function you wrote in the included file.
×
×
  • 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.