Jump to content

Lassie

Members
  • Posts

    390
  • Joined

  • Last visited

Everything posted by Lassie

  1. Hi, I want to put the field values into variables e.g.$property_title=? I used print r to view the values but I don't know how to get the value from the array. The array is Array ( [1] => Array ( [id] => 1 [label] => Property Title [value] => A New Property 2 ) [2] => Array ( [id] => 2 [label] => Estate Agent [value] => Me ) [3] => Array ( [id] => 3 [label] => Property Reference [value] => 1123 ) [4] => Array ( [id] => 4 [label] => Brief Description [value] => Brief description ) [6] => Array ( [id] => 6 [label] => Add Brochure [value] => http://localhost/wordpress/site2/files/gravity_forms/2-bb2623c01495bb311c734b2c44390d23/2013/10/Drovers-Way-Bude-Cornwall.pdf ) [7] => Array ( [id] => 7 [label] => Post Code [value] => EX23 9DZ ) )
  2. I am trying to retrieve data from a gravity form and wish to extract the data into variables that I can then use. I have got the values in an array but can't figure out how to put them into variables. This is my code <?php $lead_id = 3; $lead = RGFormsModel::get_lead( $lead_id ); $form = GFFormsModel::get_form_meta( $lead['form_id'] ); $values= array(); foreach( $form['fields'] as $field ) { var_dump($fields); $values[$field['id']] = array( 'id' => $field['id'], 'label' => $field['label'], 'value' => $lead[ $field['id'] ], ); } ?>
  3. upload.phpI want to modify a script to add pdf as an allowable extension. I have tried modifying the array of the $allowable extensions but pdf files are still rejected on upload. Is there anything else in this script I need to modify? these seem to be relevant parts line 62 class qqFileUploader { private $allowedExtensions = array(); private $sizeLimit = 10485760; private $file; function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760){ $allowedExtensions = array_map("strtolower", $allowedExtensions); $this->allowedExtensions = $allowedExtensions; $this->sizeLimit = $sizeLimit; line 134 $pathinfo = pathinfo($this->file->getName()); $filename = $pathinfo['filename']; //$filename = md5(uniqid()); $ext = $pathinfo['extension']; if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){ $these = implode(', ', $this->allowedExtensions); return array('error' => 'File has an invalid extension, it should be one of '. $these . '.');// list of valid extensions, ex. array("jpeg", "xml", "bmp") line 162 $allowedExtensions = array( "jpeg", "jpg", "png", "gif", "mp3", "ogg", "mp4", "webm", "ogv","pdf" );
  4. Hi Thanks, Well I put the !$result in to check just that and the db does hol data for this query. ?
  5. I have a simple query and need to print the result. My code does not print a resulr but the query is valid and returns a result. Any help appreciated. $query = ("SELECT * FROM wp_book WHERE Author_ID = '$Author_ID'"); $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result) { echo "<br />"; echo"No Result"; } echo"Result"; while($row = mysql_fetch_assoc($result)){ echo $row['WorkingTitle']; }
  6. Found the error Missed putting this in and had it within the while $i=0; $size=3; echo"<tr>";
  7. I want to show a table with a max of three columns. I am using an if statement to count the rows and then start a new row (after 3 cols), I cant see my error. The output just gice one col with all the data in it. Any help appreciated. <form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST" id="cover" enctype="multipart/form-data"> <table width="700"><?php /* display picture and radio button */ //add counter for more than 3 images $i=0; $size=3; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $coverID=$row['coverID']; echo"<tr>"; echo "<td>"; echo"<img src=\"/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" />"; echo "<input type = 'radio' name ='cover' value= '$coverID'/>"; ?> <br /> <input type="submit" value="submit"> <?php echo"</td>"; $i++; if($i==$size) { echo "</tr><tr>"; $i=0; } } ?></table> </form><?php
  8. Ok I have found the error.It was in the the form.I needed to close the form otside of the while loop. Thank you everyone. ?><form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST" id="cover" enctype="multipart/form-data"> <table width="700"><tr><?php /* display picture and radio button */ while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $coverID=$row['coverID']; echo"<img src=\"/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" />"; echo"<td>"; echo "<input type = 'radio' name ='cover' value= '$coverID'/>"; ?> <input type="submit" value="submit"> <?php echo"</td>"; } ?></tr></table> </form><?php
  9. Ok Here is the relevant part. <ul id="demo-menu"> <li class="demo-menu-link"><a href="?page=submenu6">Author Registration</a></li> <li class="demo-menu-link"><a href="?page=submenu5">Cover</a></li> <li class="demo-menu-link"><a href="?page=submenu4">Upload</a></li> <li class="demo-menu-link"><a href="?page=submenu3">Marketing</a></li> <li class="demo-menu-link"><a href="?page=submenu2">Book Idea</a></li> <li class="demo-menu-link"><a href="?page=Authors2.php">General</a></li> </ul> <div style="clear:right;"></div> <div class="wrap"> <div id="icon-plugins" class="icon32"></div> <h2>Authors Register and Upload your book idea</h2> <h4>These pages allow you to add additional information to support your book idea or synopsis.<br /> Please register your information in the following order.....</h4> <hr/> <h2>Please upload your book cover or choose one from the selection</h2> <p>All book ideas require a cover. Your choice can be changed at a later date.</p>not Submitted<div class="wrap"><p>choose from one of the covers below</p></div><form action="" method="POST" id="cover" enctype="multipart/form-data"> <table width="700"><tr><img src="/wordpress_3/wp-content/plugins/Authors2/jackets/old_cover.png" /><td><input type = 'radio' name ='cover' value= '1'/> <input type="submit" value="submit"> </tr></table> </form><img src="/wordpress_3/wp-content/plugins/Authors2/jackets/blue_cover.png" /><td><input type = 'radio' name ='cover' value= '2'/> <input type="submit" value="submit"> </tr></table> </form><img src="/wordpress_3/wp-content/plugins/Authors2/jackets/GDL2.png" /><td><input type = 'radio' name ='cover' value= '3'/> <input type="submit" value="submit"> </tr></table> </form>
  10. Sorry. Only one button is active.Three images show each with a radio button and a submit button, but only the first one will process the form whem the radio button is checked and the submit button pressed.
  11. Hi Thanks. Yes i have just discovered that and it now works. I still cant get the buttons to work though. Only the first one works. ?><form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST" id="cover" enctype="multipart/form-data"> <table width="700"><tr><?php /* display picture and radio button */ while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $coverID=$row['coverID']; echo"<img src=\"/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" />"; echo"<td>"; echo "<input type = 'radio' name ='cover' value= '$coverID'/>"; ?> <input type="submit" value="submit"> </tr></table> </form><?php }
  12. Hi Thanks This is the code echo $coverID gives the correct value(although only one radio button works but that is not passed in the link. //process selection of cover if (isset($_POST['cover'])) { $coverID=$_POST['cover']; echo $coverID; ?> &nbsp <ul><li class="demo-menu-link"><a href="?page=submenu7&coverID=$coverID">Finnished Cover</a></li></ul><?php exit(); } else{ echo "not Submitted"; }
  13. I have now got the form to submit with a vale but I can only get one button(out of a test of 3) to work. Just to emblish this post the link goes to the following code. The idea is to pass the cover id to the finished cover function which will display the selected cover with other data. The $_GET['coverID'] just gives me $coverID. not the ID value which is numeric. //output page content for each plugin submenu page if ($_GET['page']== "submenu7"){ $cover=$_GET['coverID']; echo $_GET['coverID']; FinnishedCover($cover); }elseif($_GET['page'] == "submenu6") { AuthorRegistration_page(); } elseif ($_GET['page'] == "submenu5") { cover(); } elseif ($_GET['page'] == "submenu4") { Upload_page(); } elseif ($_GET['page'] == "submenu3") { Marketing_page(); } elseif ($_GET['page'] == "submenu2") { Synopsis_page(); } else { //page 1 is default General_page(); }
  14. I have a function to display some images and allow a user to select a choice via a radio button.The value is then passed to another function. I have 2 problems My selection is not being passed back and I cant assign the value to a query sring in a link to another page. On the form do i need to add checked? Any help appreciated. function cover() { echo'<h2>Please upload your book cover or choose one from the selection</h2> <p>All book ideas require a cover. Your choice can be changed at a later date.</p>'; //process selection of cover if (isset($_POST['submit'])) { $coverID=$_POST['cover']; echo $coverID; ?> &nbsp <ul><li class="demo-menu-link"><a href="?page=submenu7&coverID=$coverID">Finnished Cover</a></li></ul><?php exit(); } else{ echo "not Submitted"; } global $wpdb; $query = "select * from wp_cover"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result){ return false; } echo'<div class="wrap"><p>choose from one of the covers below</p></div>'; ?><form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST" id="cover" enctype="multipart/form-data"> <table><tr><?php /* display picture and radio button */ while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $coverID=$row['coverID']; echo"<img src=\"/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" />"; echo"<td>"; echo $coverID; echo "<Input type = 'Radio' Name ='cover' value= '$coverID'/>"; ?> </tr></table> <input type=submit value=submit> </form><?php } }
  15. Thank you I will look into that. I will need it when I get the basic functionality working.
  16. Right, Thanks guys. I cleared the cache and used the following. echo"<img src=\"/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" />";
  17. still no image. If it helps this is the full code as now. function display covers is suppossed to show some covers a user can choose from.Next step would be to pass the id of the selected cover and create an image with narrative overlayed. I also therefore need to both display the image and make it selectable. //function for submenu 5 function cover() { echo'<h2>Please upload your book cover or choose one from the selection</h2> <p>All book ideas require a cover. Your choice can be changed at a later date.</p>'; //confirm book idea has been registered //Get book id use session variable //confirm with book title ?> <div style="text-align: center"> <table width = \"390\" border = 0 align="left"> <tr><td> <form action="" method="post" enctype="multipart/form-data" name="uploadImage" id="uploadImage"> <fieldset> <legend>Upload Your Book Cover</legend> <p> <label for="image">Upload image:<em class="required">(only jpg,gif,png.Max size 4mb)</em></label> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" /> <input type="file" name="image" id="image" /> </p> <p> <input type="submit" name="upload" id="upload" value="Upload" /> </p></fieldset> </form> </td></tr></table> </div> <br /> <?php display_covers(); //get book info $salt = rand(10000, 99999); $hash = md5($_SESSION[book_id] . $salt); global $wpdb; echo "<br />"; $query = ("SELECT * FROM wp_book WHERE Book_ID = $_SESSION[book_id]"); $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result) { echo"No Result"; } $row = mysql_fetch_array($result, MYSQL_ASSOC); $WorkingTitle = $row['WorkingTitle']; $Author = $row['AuthorName']; $_SESSION[WorkingTitle] = $WorkingTitle; $_SESSION[AuthorName] = $AuthorName; $str = $Author; $str1 = $WorkingTitle; $cover = "old_cover.png"; echo "<img src='http://localhost:8888/test_upload/image-save.php?str=$str&str1=$str1&hash=$hash&cover=$cover'/>"; //save hash value in database $query = "UPDATE wp_book SET BkCover='$hash' WHERE Book_ID='$_SESSION[book_id]'"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (mysql_affected_rows() == 1) { // If it ran OK. $message = "You have completed registering your book idea"; //set session variable book_id } if (!mysql_affected_rows() == 1) { echo "Your cover could not be registered"; exit(); } } function display_covers() { global $wpdb; $query = "select * from wp_cover"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result){ return false; } echo'<div class="wrap"><p>choose from one of the covers below</p></div>'; echo'<div id="main">'; echo'<table class="main" cellpadding="2">'; //echo"<caption>Please choose a book cover</caption>"; echo' <thead><tr><td colspan="5" ><h6 class="main">Book Covers</h6></td></tr></thead>'; $i = 0; $size = 3; echo "<tbody><tr>"; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { /* display picture */ echo'<td class="main">'; echo"<img src=\"/htdocs/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" />"; echo"</td>"; $i++; if ($i == $size) { echo "</tr><tr>"; $i = 0; } } }
  18. Right.But echo"<img src=\"/http://localhost:8888/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" / still doesnt display my images?
  19. http://localhost:8888/Applications/MAMP/htdocs/wordpress_3/wp-content/plugins/Authors2/jackets/old_cover.png gives path not valid http://localhost:8888/wordpress_3/wp-content/plugins/Authors2/jackets/old-cover.png shows the image. Can I use a url here?
  20. yes, i think so. I am using a mac and my web root is htdocs.The main application is wordpress and I am building a plugin to dispay on the admin page.
  21. Thanks guys .They both work in terms of getting rid of the syntax error. However my images are not dispalyed. The while loop shows the file names but doesnt show the image. Have I missed something? Code at present function display_covers() { global $wpdb; $query = "select * from wp_cover"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result){ return false; } echo'<div class="wrap"><p>choose from one of the covers below</p></div>'; echo'<div id="main">'; echo'<table class="main" cellpadding="2">'; //echo"<caption>Please choose a book cover</caption>"; ?> <thead><tr><td colspan="5" ><h6 class="main">Book Covers</h6></td></tr> </thead> <?php $i = 0; $size = 3; echo "<tbody>"; echo "<tr>"; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { /* display picture */ ?> <td class="main"> <?php echo $row['pix']; echo"<img src=\"/Applications/MAMP/htdocs/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" />"; echo"</td>"; $i++; if ($i == $size) { echo "</tr><tr>"; $i = 0; } } }
  22. Thanks I'll try that. I was getting a syntax error.
  23. I want to retrieve an image id from a db and show the images. I cant get the syntax right for the image tag.Any help appreciated. function display_covers() { global $wpdb; $query = "select * from wp_cover"; $result = mysql_query($query)or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result) return false; echo'<div class="wrap"><p>choose from one of the covers below</p></div>'; echo'<div id="main">'; echo'<table class="main" cellpadding="2">'; //echo"<caption>Please choose a book cover</caption>"; ?> <thead><tr><td colspan="5" ><h6 class="main">Book Covers</h6></td></tr> </thead> <?php $i=0; $size=3; echo "<tbody>"; echo "<tr>"; while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { /* display picture */ ?> <td class="main"> <?php echo"<img src="/Applications/MAMP/htdocs/wordpress_3/wp-content/plugins/Authors2/jackets/"{.$row['pix'].}""/>"; echo"</td>"; $i++; if($i==$size) { echo "</tr><tr>"; $i=0; } } }
×
×
  • 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.