Jump to content

JREAM

Members
  • Posts

    127
  • Joined

  • Last visited

Everything posted by JREAM

  1. I got tihs right, and it outputs all the posts in the export() function, ie some random text: title - sdfasdf, desc - asdfasfd $jTitle = clean($_POST['title']); $jDesc = clean($_POST['desc']); $jPrice = clean($_POST['price']); $jProg = clean($_POST['progress']); $jPri = clean($_POST['priority']); $jAC = clean($_POST['assign_client']); $jDateDue = clean($_POST['date_due']); $jDateMod = dateTime; echo extract($_POST); foreach($_POST as $key =>$val) { echo $key . ' - ' . $val . '<br />'; } $sql = mysql_query("INSERT INTO $sqlcol SET `title`='$jTitle', `desc`='$jDesc', `price`='$jPrice', `progress`='$jProg', `priority`='$jPri', `assign_client`='$jAC', `date_due`='$jDateDue', `date_modified`='$jDateMod'"); if($sql) {$status = 'Project Created!';} The Data gets inserted into the Database but its blank. If I force a MySQL Error and remove the ` ` ticks, it prints: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc='', price='', progress='', priority='', assign_client='', ' at line 3 Which shows me the posts arent being placed into that statement. Otherwise I get the 'Project Created!' message when I put the `` ticks back. All clean() does is: function clean($str) {mysql_real_escape_string($str);}
  2. I got a column in a MySQL table that grabs out a number value, like: 1, 2, 3, 4. When I echo it into PHP you get lets say, while (...) { echo $row; } and it will come out as a digit. Is there a way to assign the #'s a value so that, echo $row // if row == 1 change the text to 'favorite'; echo $row // if row == 2 change the text to 'non-favorite'; etc.. Is there a good way to go about such a thing? I dont want it to change the database (because if a global setting changed it needs to stay consistent)
  3. Is there a faster way to apply "mysql_real_escape_string" through the Posts of a form? Because Im going to have to insert these a LOT `title`='".mysql_real_escape_string($_POST['title'])."', `content`='".mysql_real_escape_string($_POST['content'])."', `public`='".mysql_real_escape_string($_POST['public'])."',
  4. You should define the function outside of a loop, because you can re-use and reload it any amount of times you want, for example: function TryThis($anything) { echo "Hey It's: $anything <br />"; } for ($i = 0; $i < 5; $i++) { TryThis($i); }
  5. you would use apache mod_rewrite set my .htaccess ie: Options +FollowSymlinks RewriteEngine on RewriteRule (.*)\.php $1.dog
  6. Got it // Make All the Files $files = array('header.tpl', 'footer.tpl', 'sidebar.tpl', 'style.css'); for ($i = 0; $i < count($files); $i++) { $make = "../templates/".$theme_name.'/'.$files[$i]; if ($handle = fopen($make, 'w')) { echo $files[$i] . ' Created '; } fclose($handle); }
  7. Could you help me loop these files faster? The actual code i have now: $files = "../templates/".$themename."/header.tpl"; $handle = fopen($files, 'w'); fclose($handle); $files = "../templates/".$themename."/footer.tpl"; $handle = fopen($files, 'w'); fclose($handle); $files = "../templates/".$themename."/sidebar.tpl"; $handle = fopen($files, 'w'); fclose($handle); $files = "../templates/".$themename."/style.css"; $handle = fopen($files, 'w'); fclose($handle); I was thinking the file names could be an array like, $set = array('header.tpl', 'footer.tpl',); // etc.. and something like, for ($i = 0; $i < count($set); $i++) { $files = "../templates/".$themename.$set[$i]; $handle = fopen($files, 'w'); fclose($handle); } That actually might work but i would like to check so i dont accidently create a ton of files on my ocmputer or crash it !!
  8. Hey But I wanted the names also to be generated from the array like this so it generates the table ROW based on my function array list: INSERT INTO table SET $array[$name]='".$_POST[$array[$val]."'"); Because then I can re-use the same thing for my other forms for creating a page. I don't know how to retrieve the POST form name
  9. Hey, basically Im trying to make this loop act like the statements below this box. But I keep getting an undefined index so the Array Values aren't reading through I think. I tried a foreach loop, but my logic must be messed up on getting these arrays right, could anyone help me! So each item is like: $title = $_POST['title']; $slug= $_POST['slug']; etc .. $items = 'title, slug, breadcrumb, keywords, description, content, parent_id, position'; // Make the Array $values = explode(",", $items); // Loop Through Each Value for ($i = 0; $i < count($values); $i++) { echo $values[$i] . '=' . $_POST[$values[$i]]; } This one works perfectly, Im testing this and the above on the same page // This Works but I don't want to use it $title = mysql_real_escape_string($_POST['title']); $slug = mysql_real_escape_string($_POST['slug']); $breadcrumb = mysql_real_escape_string($_POST['breadcrumb']); $keywords = mysql_real_escape_string($_POST['keywords']); $description = mysql_real_escape_string($_POST['description']); $content = mysql_real_escape_string($_POST['content']); $parent_id = mysql_real_escape_string($_POST['parent_id']); $position = mysql_real_escape_string($_POST['position']);
  10. Okay I had it backwards $colNames = explode(',',$items);
  11. trying to do explode $colNames = explode($items, ',');
  12. How would I go about doing this? Because the items in the createItem list (below) only appear as $item. createItem($sqlcol, 'title, slug, breadcrumb, keywords, description, content, parent_id, position'); How would I make colNames have them broken down like that? function createItem($sqlcol, $items) { $colNames = array($items); print_r($items); // .. etc ..
  13. Oh i use asort BEFORE the thing, cool!! ty!
  14. THis is a weird question I am trying to sort out. I got this that makes an array right, But i want to sort the output before its printed: I need the variable so I can sort($position) for the output foreach ($output as $value) { // How do I grab the $position from // $output[$i] so I can $sort($position) echo $value; } (I just removed stuff to make it shorter, it works) while (//etc..) { // Removed stuff here to make it shorter $output[$i] = "<tr> <td style='padding: 5px;'>$position</td> <td style='padding: 5px;'>$title</td> </tr>"; } PS: How do i mark something as solved ??
  15. Oh bummer. I will use a separate page so its not so cluttered i guess. Thank you for a fast reply
  16. I have a question! If I have a link: <a href='delete-user.php?id=$id'>Delete</a> And instead I set it to <a href='<?php echo $_SERVER['PHP_SELF']; ?>?id=$id'>Delete</a> Ok so far! Then I place the code that was in delete-user.php into the index.php. I know how to check if a form was submitted, I just use the name of a form field.. So would I do something like this? <a name="delete" href='<?php echo $_SERVER['PHP_SELF']; ?>?id=$id'>Delete</a> Would that suffice for passing a delete variable through the page so I could do: if (isset($_POST['delete'])) { // etc.. }
  17. I can't seem to get these Arrays to separate. if $first_listed_mp3s' are found in $data[$i] -- Don't list in File. So I would do an if statement inside the while loop and make $data[$i] = ''; if it is found, but I cant get anything to work. 1. I'm trying to have the top items at the top of the file, 2, and the rest of them listed below in whatever order they fall, 3. but I don't want the files listed twice and thats what is happening. <?php function list_mp3s () { // Set Directory and Options $directory = 'public/mp3s/'; $handler = opendir($directory); $fp = fopen('public/apps/mp3_player/playlist.xml', 'w'); // Write the data as blank, incase new files are added. $data = ''; // Start the top of the File $top_of_file .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $top_of_file .= "<xml>\n"; fwrite($fp, $top_of_file); // 111111111111111111111111111111111111111111 // Write the Top songs to Display $first_listed_mp3s = array( 'DREAM_ON.mp3', 'STRAY_DOG.mp3', 'JOLIE.mp3', 'AMERICAN_TRUCKER.mp3', 'LOTTIE.mp3', 'BYE_BABY.mp3', 'FIRE_IN_THE_SUN.mp3', 'JANE_AND_ME.mp3', '', ); for ($i = 0; $i < count($first_listed_mp3s); $i++) { $top_data[$i] .= "\n<track>\n"; $top_data[$i] .= "<path>$directory$first_listed_mp3s[$i]</path>\n"; $top_data[$i] .= "<title>".ucwords(strtolower(str_replace("_"," ", str_replace(".mp3","", $first_listed_mp3s[$i]))))."</title>\n"; $top_data[$i] .= "</track>\n"; fwrite($fp, $top_data[$i]); } // Counter $i = 0; // 222222222222222222222222222222222222222 // Function Power while ($file = readdir($handler)) { if ($file != '.' && $file != '..') { $data[$i] .= "\n<track>\n"; $data[$i] .= "<path>$directory$file</path>\n"; $data[$i] .= "<title>".ucwords(strtolower(str_replace("_"," ", str_replace(".mp3","", $file))))."</title>\n"; $data[$i] .= "</track>\n"; // Count Individual File $i++; } } print_r(array_diff($top_data, $data)); // Write Array one by one for ($i = 0; $i < count($data); $i++) { fwrite($fp, $data[$i]); } $bottom_of_file .= "\n\n</xml>\n"; fwrite($fp, $bottom_of_file); fclose($fp); // Close Entire Directory closedir($handler); } // do it list_mp3s(); ?>
  18. Thanks, I had done this: for ($j = 0; $j < count($set); $j++) { print $set[$j]; }
  19. I am printing out an array with html code in it with: print_r($set); I would like to remove the array keys and Array text, should I use str_replace and make a formula for the key value, or is there an easier way?
  20. hey i keep crashing my browser with this and it floods it like 100000 times, but i only got like 40 m3ps <script type="text/javascript" src="public/apps/mp3_player/swfobject.js"></script> <?php function list_mp3s () { $directory = 'public/mp3s/'; $appdir = 'public/apps/mp3_player/'; $results = array(); // I dont see why i have this ehre anymore $handler = opendir($directory); $i = 0; // this is to count unique instances while ($file = readdir($handler)) { if ($file != '.' && $file != '..') // look for only filenames { $data .= '<script type="text/javascript">'; $data .= 'var so = new SWFObject("public/apps/mp3_player/playerMini.swf", "mymovie", "75", "30", "7", "#FFFFFF");'; $data .= 'so.addVariable("autoPlay", "no");'; $data .= 'so.addVariable("soundPath", "'.$directory . $file . '");'; $data .= 'so.write("flashPlayer'.$i.'");'; $data .= '</script>'; $data .= '<div id="flashPlayer'.$i.'">'; $data .= 'This text will be replaced by the flash music player.'; $data .= '</div>'; $i++; // increase unique instances echo $data; // return the stuff. } } closedir($handler); } // do it list_mp3s(); ?>
  21. The 'a' works, but if i refresh the page, it adds it again, when i got: file1.mp3, file2.mp3, and file3.mp3 if i hit refresh ti will do: file1.mp3, file2.mp3, and file3.mp3, file1.mp3, file2.mp3, and file3.mp3 should I do this before i open: // this would have to go outside of the while loop $fp = fopen('data.txt', 'w'); $data = ""; fwrite($fp, $data); fclose($fp); // then the normal part here: while .... $fp = fopen('data.txt', 'a'); $data = "<track>"; $data .= "<location>$directory$file</location>"; $data .= "<image></image>"; $data .= "<annotation>$filename</annotation>"; $data .= "</track>"; fwrite($fp, $data); fclose($fp);
  22. This keeps replacing itself and there are supposed to be a long list of items <?php function list_mp3s () { $directory = 'public/mp3s/'; $results = array(); $handler = opendir($directory); while ($file = readdir($handler)) { if ($file != '.' && $file != '..') { // $filename = RemoveExtension($file); // Use this later $fp = fopen('data.txt', 'w'); $data = "<track>"; $data .= "<location>$directory$file</location>"; $data .= "<image></image>"; $data .= "<annotation>$filename</annotation>"; $data .= "</track>"; fwrite($fp, $data); fclose($fp); } }closedir($handler);} // do it list_mp3s(); ?> I can only get it to write one file, Can anyone help me put it into an array and write it at the end if thats how i do it?
×
×
  • 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.