-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
problem in deleting files from server once uploaded
mikesta707 replied to ejazshah's topic in PHP Coding Help
to delete a file, just do something like this <?php $file = "test.txt"; if (!unlink($file)) { echo ("Error deleting $file"); } else { echo ("Deleted $file"); } ?> that is assuming that the file test.txt is in the same directory as the script running. if its not you have to use the absolute or relative path to the file. what does your code look like now -
To make a preview of something, all you need to do is pass the post variables to the preview page, and output them. You also want to store those variables in hidden forms, and when the user wants to save the changes, hit submit, else, bring them back to the previous page, and repopulate the data. for example preview.php <?php $post = $_POST['my_var'];//post variable to preview echo "The value: $post"; ?> <form name="form" action="submit.php" method="post"> <input type="hidden" name="my_var" value="<?php echo $post; ?>" /> <input type="submit" value="submit" /> and submit.php would be the page that you process the form, and all that stuff
-
you do it exactly as you described doing it. are you asking how the queries go? what PHP you should use? or do you need an entire script? Do you have any code you can post to tell us where you are exactly with this project
-
javascript isn't a good way to validate data, since it can be turned off server side. if you don't know how to create input boxes, then you will have to learn HTML. if you have the SQL statement(s) down, its really just about doing a query with PHP. its quite simple, but if have no clue where to get started, learn HTML, and PHP
-
How to use methods from the same 2 included files
mikesta707 replied to DexterR's topic in PHP Coding Help
truth, I was thinking about that, but I wasn't sure if the database connection info was constant, or if you could modify it. I think its constant though, because when you set up wordpress I believe you it automatically creates its tables and what not. However, I could be making that up. more info is needed -
How to use methods from the same 2 included files
mikesta707 replied to DexterR's topic in PHP Coding Help
yeah since you are trying to basically include the same class twice, IDK if there is a way to do this. perhaps if you rename the class from the wp-config file of the second blog, you could do it -
[SOLVED] Basic regex expression. cant figure it out
mikesta707 replied to mikesta707's topic in Regex Help
excellent, thank you very much -
Alright, so im trying to make 3 regex expressions. If i can figure out how to make this specific one work, than I can probably figure out the others. it has to match a line that looks like this Warrior john 100 every line must start with warrior, has to have a name composed of only alphabet characters, and a number. Note that the spacing must be exactly like shown, it cant have 2 or more spaces between each element. I currently have std::tr1::regex rgx1("^(Warrior) [a-zA-z]) [a-zA-z]) [0-9]{1,3}$)", std::tr1::regex_constants::icase);//warrior pattern this is in C++ i know, but it uses PCRE regex expressions so i expect that it will be similar if not that same. I always had a hard time with regex, so I just can't figure it out, but i expect its a pretty simple regex pattern. thanks in advance btw the std::tr1::regex_constants::icase part just makes the pattern case insensitive
-
$_POST and backslash problem..I think
mikesta707 replied to php_beginner_83's topic in PHP Coding Help
why not lol? what you are doing could be automated with auto increment. -
not that I could see. you will have to loop through anyways to get the data regardless so its not adding much more stuff for the script to do
-
your if statements are wrong. you want to compare the values, not assign them =;// the assignment operator ==;//the comparison operator [/code] if($section=="home"){ [/code] do that for all of your if statements
-
try changing your prints to look like this <?php print $status; ?> instead of what you had. <?print $status;?> thats an invalid php tag
-
what does your code currently look like? but you could just iterate throughthe rows. While you iterate, you have several tests, and update several counters based on that test. for example //sql stuff above $arr = array(); $count = 0; $count1 = 0; $count2 = 0; while($row = mysql_fetch_assoc($query)){ $count++; if ($row['age'] < 25){ $count2++; } #etc }
-
$_POST and backslash problem..I think
mikesta707 replied to php_beginner_83's topic in PHP Coding Help
I suggest you take a look at this tutorial. I'm not sure if you have began the actual uploading part of your script, but this should explain a lot of things. FileUpload on a side note, if you have your id which should be set to auto increment if its the primary key (it should be the primary key) then you don't need to get the value for id, or pass anything into that column, as it will automatically increment for you -
Weird error in a simple fopen read script!
mikesta707 replied to drakeman's topic in PHP Coding Help
As far as that goes, I am not sure. I am running a local php server on a windows box, and for my script it returns the filename without any paths. Are you sure you just didnt have the file in question on your windows machine in the same directory as the script itself -
Weird error in a simple fopen read script!
mikesta707 replied to drakeman's topic in PHP Coding Help
Oh sorry, i misread your script for a minute. Yeah the FILES super global won't work. make sure your script is in the same directory as the file you are trying to access. the post value for your filee object is going to just be the name of the file, and not any paths leading to it. where is the file you are trying to access, and where is the script itself -
then do exactly that.. while ($teams = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo "<b>Status: </b> " . $teams['status']."<br />"; } assuming that the value for status was under the column status from your query
-
hmmm Idk why it isn't echoing anything. it works for me on my machine. do a print_R on your data array or echo $data[$c] before you do the function and make sure the right data is in there
-
that will print out a drop down menu... not the string Home Team: Team1 Team2 Team3 Team4 Team5 Team6 I'm more confused now... do you want or not want a drop down box
-
see if this function works for you function removeLast($string, $char){ $pos = strrpos($string, $char); $newString = substr_replace($string, '', $pos, strlen($string)); return $newString; } with the following code $string = "INSERT INTO `tblName` VALUES(1,'att','AT&T ','5700','50',' ',' ',' ');,"; echo removeLast($string, ','); the output is INSERT INTO `tblName` VALUES(1,'att','AT&T ','5700','50',' ',' ',' ');
-
Special letters disappearing very unrationally
mikesta707 replied to aproblem's topic in PHP Coding Help
do you want someone to fix it for you? or do you want help? there is a freelance forum near the bottom of the forum directory if you want someone to do it for you. Can you perhaps provide a piece of the code that is storing the data/showing the data -
what should the output look like?
-
well the code you posted doesn't do that at all. post the code that creates the output Home Team: Team1 Team2 Team3 Team4 Team5 Team6 but it should look something like while ($teams = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo "Hometeam: ".$teams['teamname']."<br />"; } assuming you wanted to precede each team name with the word Home Team
-
Weird error in a simple fopen read script!
mikesta707 replied to drakeman's topic in PHP Coding Help
you are using a file type of form, so you need to use the $_FILE superglobal, as opposed to the post superglobal. to get the original file name of the file you choose in that form, you use $_FILES['filee']['name'] so try changing your script to <?php print"<form method='post' action=$PHP_SELF>"; print"<input name='filee' type='file' id='txtarchivo4'>"; print"<input type='submit' name='abrir' value=\"Leer Archivo\">"; print"<input type='submit' name='limpiar' value=\"Limpiar Datos\">"; print"</form>"; if(isset($_POST['abrir'])) { //Cargamos el contenido obtenido de una variable llamada fichero $fichero = $_FILES['filee']['name']; //Abrimos el fichero en modo lectura $descriptorfichero = fopen("$fichero","rb"); //Hasta que no lleguemos al final del fichero while(!feof($descriptorfichero)) { //Capturamos 4096 caracteres dentro de la linea, //o menos si hay un retorno de carro antes $buffer = @fgets($descriptorfichero,4096); //Soltamos el texto, aƱadiendo<BR> detras echo $buffer."<br>"; } } else { $buffer = NULL; } ?> if that doesn't work, output the $fichero variable, and see what it holds in it -
I'm confused, do you just want to print the variable teamname? why dont you just print it? I really dont understand your question, could you possibly clarify?