PHP - Wordpress And Regular Php Files
Hello. I'd like to ask something to experts. I have wordpress blog , for example http://site.com . And in the root directory where my site is located i have other file.php (http://site.com/file.php). So, can i use wordpress header.php and footer.php files in my file.php , the only thing i want to do is that file.php have the same header and footer that wordpress has.
Thank you Similar TutorialsI am using WPSQT plugin in my blog site .I code some files in PHP also.how to add that files in plugin files.
I have a php tutorial that I followed for creating, inserting, selecting and updating a MySQL database with php. Everything works fine so I wanted to put it into Wordpress. I took the code and placed it into the wordpress page and everything worked just fine except the update function. Here is the tutorial I used. http://www.phpsimple.net/mysql_insert_record.html It is also the part I am having trouble with. I am able to create a record and I am also able to select a record but when I choose "update" the form doesn't load the data. It will outside the website but not inside wordpress. I am hoping this is not vague but because of my inexperience I am not sure what else to say. I will be more than happy to provide any other information you need. So far I have managed to create an upload process which uploads a picture, updates the database on file location and then tries to upload the db a 2nd time to update the Thumbnails file location (i tried updating the thumbnails location in one go and for some reason this causes failure) But the main problem is that it doesn't upload some files Here is my upload.php <?php include 'dbconnect.php'; $statusMsg = ''; $Title = $conn -> real_escape_string($_POST['Title']) ; $BodyText = $conn -> real_escape_string($_POST['ThreadBody']) ; // File upload path $targetDir = "upload/"; $fileName = basename($_FILES["file"]["name"]); $targetFilePath = $targetDir . $fileName; $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION); $Thumbnail = "upload/Thumbnails/'$fileName'"; if(isset($_POST["submit"]) && !empty($_FILES["file"]["name"])){ // Allow certain file formats $allowTypes = array('jpg','png','jpeg','gif','pdf', "webm", "mp4"); if(in_array($fileType, $allowTypes)){ // Upload file to server if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){ // Insert image file name into database $insert = $conn->query("INSERT into Threads (Title, ThreadBody, filename) VALUES ('$Title', '$BodyText', '$fileName')"); if($insert){ $statusMsg = "The file ".$fileName. " has been uploaded successfully."; $targetFilePathArg = escapeshellarg($targetFilePath); $output=null; $retval=null; //exec("convert $targetFilePathArg -resize 300x200 ./upload/Thumbnails/'$fileName'", $output, $retval); exec("convert $targetFilePathArg -resize 200x200 $Thumbnail", $output, $retval); echo "REturned with status $retval and output:\n" ; if ($retval == null) { echo "Retval is null\n" ; echo "Thumbnail equals $Thumbnail\n" ; } }else{ $statusMsg = "File upload failed, please try again."; } }else{ $statusMsg = "Sorry, there was an error uploading your file."; } }else{ $statusMsg = 'Sorry, only JPG, JPEG, PNG, GIF, mp4, webm & PDF files are allowed to upload.'; } }else{ $statusMsg = 'Please select a file to upload.'; } //Update SQL db by setting the thumbnail column to equal $Thumbnail $update = $conn->query("update Threads set thumbnail = '$Thumbnail' where filename = '$fileName'"); if($update){ $statusMsg = "Updated the thumbnail to sql correctly."; echo $statusMsg ; } else { echo "\n Failed to update Thumbnail. Thumbnail equals $Thumbnail" ; } // Display status message echo $statusMsg; ?> And this does work on most files however it is not working on a 9.9mb png fileĀ which is named "test.png" I tested on another 3.3 mb gif file and that failed too? For some reason it returns the following Updated the thumbnail to sql correctly.Updated the thumbnail to sql correctly. Whereas on the files it works on it returns REturned with status 0 and output: Retval is null Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif' Failed to update Thumbnail. Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif'The file rainbow-trh-stache.gif has been uploaded successfully. Any idea on why this is? Hello I have a simple question about file handling... Is it possible to list all files in directories / subdirectories, and then read ALL files in those dirs, and put the content of their file into an array? Like this: array: [SomePath/test.php] = "All In this php file is being read by a new smart function!"; [SomePath/Weird/hello.txt = "Hello world. This is me and im just trying to get some help!";and so on, until no further files exists in that rootdir. All my attempts went totally crazy and none of them works... therefore i need to ask you for help. Do you have any ideas how to do this? If so, how can I be able to do it? Thanks in Advance, pros I am trying to check my youtube code value and see if &rel=0 has been added to it and if not added it. I suck at regular exp can someone help? Hello everyone,
example string
<?php $string = ""; $string .= "<textarea id='convert'> 'AA' </textarea>"; $string .= "<textarea id='convert'> 'BB' </textarea>"; $string .= "<textarea id='not_convert'> 'AA' </textarea>"; $string .= "<textarea id='not_convert'> 'DD' </textarea>"; ?>I want to change 'AA' to 'ZZ' which is inside textarea with the id convert only. How is it possible with the help of regular expression? Hi people,
i need to find 16x150gr in Dried Pomegranate Arils16x150gr but the format can vary from
Mt Ceder Balsamic Vinegar 12x250ml to
Mt Ceder Balsamic Vinegar 2x2ltr to
Dried Kalamata Olives 4x1kg. i guess you got the drift
i tried something like : '/[1-9]+x[1-9]+[a-z]+/' but i am so useless at regex.
Thank you!
Code: [Select] <pre> <pre class="brush:cpp"> <pre class="brush:javascript"> Those can be cpp,javascript,python ... etc. I need to change/replace these into: Code: [Select] <pre> <pre class="brush:cpp"> <pre class="brush:javascript"> Those can be cpp,javascript,python ... etc. I need a generic regular expression for this? Can anyone provide the generic regular expression for this to replace? Trying=> $abc = str_replace(array($generic-regular-expression),'<pre> or <pre class="brush:cpp"> or <pre class="brush:javascript"> ..... ',$str); Can anyone help me. I have very little knowledge about programming and coding and php, but I am tutoring myself on these. I want to write a code that will search for a movie in this website search => http://myandyourface.com/DELETE/imdb-poster.php. NOTE: in searching for the movie, the movie name with more than one word can be type in in combination form by using the + sign. For example, the movie "the vow", typing that into the search box will be so => the+vow. As an example, I got the result as show below: {"Title":"The Vow","Year":"2012","Rated":"PG-13","Released":"10 Feb 2012","Genre":"Drama, Romance","Director":"Michael Sucsy","Writer":"Jason Katims, Abby Kohn","Actors":"Rachel McAdams, Channing Tatum, Sam Neill, Jessica Lange","Plot":"A car accident puts Paige (McAdams) in a coma, and when she wakes up with severe memory loss, her husband Leo (Tatum) works to win her heart again.","Poster":"http://ia.media-imdb.com/images/M/MV5BMjE1OTU5MjU0N15BMl5BanBnXkFtZTcwMzI3OTU5Ng@@._V1_SX320.jpg","Runtime":"N/A","Rating":"N/A","Votes":"N/A","ID":"tt1606389","Response":"True"} So, this is what I wanted to do, I wanted to write a php code expression that will search for a specific movie and provide the result as above,and then using the regex and str_replace, and others, I will be able to remove all the above detail information and have ONLY the image link as in above, which is => http://ia.media-imdb.com/images/M/MV5BMjE1OTU5MjU0N15BMl5BanBnXkFtZTcwMzI3OTU5Ng@@._V1_SX320.jpg I will appreciate any help in creating a code for this Thanks! Hey I'm pretty new to regular expression, so I might have made a silly mistake. I want to check if there are any symbols/special characters (not letters or numbers) in a string. I have the code below. function validateKeywords($kw) { if (preg_match("/[^A-Za-z0-9]/", $kw)) { echo 'validation of keywords failed<br />'; return false; // String contains symbols (not letters or numbers) - incorrect format! } else { echo 'validation of keywords succeeded<br />'; return true; // Correct format } } // Testing validateKeywords('some random string I wrote for testing purposes'); // should succeed validateKeywords('some random 10 string I wrote for testing purposes 2010'); // should succeed validateKeywords('some random, string, I wrote for 19 testing purposes'); // should fail validateKeywords('some, random, string I wrote, for testing purposes'); // should fail The problem is that all 4 calls return false and print that the validation failed. So, where did I mess up? Thanks! This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=306546.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=325429.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=325430.0 Hi; i would like to search for a regular expression to grab all printf occurences including the folowing senarios :
printf("something"); printf("something", variables); printf("something", variables, variables); printf("something);something", variables, variables);To simplify the third and fourth cases, the regex should start from printf(" and go intil it find ); with a white space after it. But i didn't realise how to do it. This trick should work also for the first and second case. Thanks Edited by Dareros, 26 September 2014 - 01:27 PM. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=315144.0 Hi, I've got a form where the user submits a date as a text field (as 12-12-2012 for example) called closing. The form submits fine without my regular expression validation, but whenever I try to validate it, it returns the error message I wrote for if no results turn up. Ive tried: Code: [Select] <?php if (!preg_match ("[0-9]{2}-[0-9]{2}-[0-9]{4}", $_POST["closing"])) { $_SESSION["report"] = "<b>Error:</b> Date is in the wrong format. It must be dd-mm-yyyy<br />"; $_SESSION["reportcount"] = 0; } ?> and Code: [Select] <?php if (!preg_match ("\d{2}-\d{2}-\d{4}", $_POST["closing"])) { $_SESSION["report"] = "<b>Error:</b> Date is in the wrong format. It must be dd-mm-yyyy<br />"; $_SESSION["reportcount"] = 0; } ?> Any ideas? This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=316160.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=317585.0 i need to split words and add to a array from filter input. i can split words with [ ] (Space character). But also i need to not split "word1 word2" with space character. for example: Filter input "word1 word2" word3 word4 my array will need to be like this after split arr[0] = word1 word2 arr[1] = word3 arr[2] = word4 can some one help me about this? By the way im sorry for my poor english Thanx This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=341968.0 |