Jump to content

SkyRanger

Members
  • Posts

    738
  • Joined

  • Last visited

Everything posted by SkyRanger

  1. Thanks maxxd, yeah I heard a lot of nightmares about the $)_REQUEST plan on used the $_POST method. Thinking I will take another stab at it tomorrow with fresh eyes. Been working on this plugin for the past 14hrs so far just today (going on 12 days straight) (honestly can't wait to be done...lol). Tonight's mission is to finish reading how all this works and learning how I messed it up so I can fight with it another day. You have informed me a lot on how it works which is greatly appreciated. Go enjoy your wine...lol, I am going for another beer.
  2. omg maxxd no that is perfect you never missed anything. After pulling my code apart (past 24 hrs) and starting to see some of the errors that might be happening. I am running codelobster which i like and loading up the edit file guess I was a little tired when I coded that and found a few errors. Will post update once I do a little more studying on ajax and wordpress and try to figure out the error in my ways (Getting close to finally finishing this plugin at 80% mark) just need to sort out edit part and another section in the admin so thanks for your assistance so far. Had come in handy having another set of eyes.
  3. Just a heads up this is my first try at a plugin for wordpress. I have done some research on the form ajax jquery and ended up changing the action to: <?php echo admin_url('admin-ajax.php'); ?> and adding <input type="hidden" name="action" value="acikudos_ajax_handler"> to my form but now instead of just a blank white page I get a blank white page with a 0 on it and not submitting form. ps: if this is now suppose to be in javascript can a mod or admin please move it over.
  4. After hours of beating head off desk and not being able to figure out what is going on I scrapped most of the code and expanded with more functions with doing some reason online with some examples and trying to implement them in to my own code. So first sorry if this is the wrong area for this, i am getting the error in the acikudos-update.php script and I can not figure out why: acikudo-plugin.php function acikudos_enqueue_script() { wp_enqueue_script( 'acikudos', plugins_url( ACI_KUDOS_URL.'/js/kudoform.js', __FILE__ ), // URL path relative to the folder of the PHP script this code is placed in array( 'jquery' ) // Requires jQuery, make sure it's loaded first ); wp_localize_script( 'acikudos', // Name of script, from above 'acikudos', // Name of JavaScript variable array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), ) ); } add_action( 'wp_enqueue_scripts', 'acikudos_enqueue_script' ); acikudos-edit.php (this works) $kudoacct = $_GET['acct']; $tablename=acikudos_table_name(); $editkudos = $wpdb->get_results( "SELECT * FROM $tablename WHERE kudoacct = '$kudoacct'"); foreach ( $editkudos as $editkudo ) { ?> <form name="acikudos-update" id="acikudos-update" method="post" action="<?php echo plugins_url( 'advantage-kudos/include/acikudos-update.php' ); ?>" enctype="multipart/form-data"> <table> <tr> <td>Agent Name</td> <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <td><input name="kudoagent" type="text" value="<?php echo $editkudo->kudoagent; ?>" /></td> </tr> <tr> <td>Agent ID</td> <td></td> <td><input name="kudoagentid" type="text" value="<?php echo $editkudo->kudoagid; ?>" /></td> </tr> <tr> <td>Agent Location</td> <td></td> <td><select name="agentloc" size="1"> <option value="<?php echo $editkudo->kudoloc; ?>"><?php echo $editkudo->kudoloc; ?></option> <option value="Amherst Center">Amherst Center</option> <option value="Charlottetown Center">Charlottetown Center</option> <option value="Kingston Center">Kingston Center</option> </select></td> </tr> <tr> <td>Agent Queue</td> <td></td> <td><select name="kudoclient" size="1"> <option value="<?php echo $editkudo->kudoclient; ?>"><?php echo $editkudo->kudoclient; ?>"</option> <option value="AR">AR</option> <option value="Eastlink Tech Support">Eastlink Tech Support</option> <option value="PNI">PNI</option> </select></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td>Customer Name</td> <td></td> <td><input name="kudocust" type="text" value="<?php echo $editkudo->kudocust; ?>"/></td> </tr> <tr> <td>Customer Account #</td> <td></td> <td><input name="kudoacct" type="text" value=" <?php echo $kudoacct; ?>" /></td> </tr> <tr> <td>Kudos</td> <td></td> <td><textarea cols="50" name="kudomsg" rows="5"><?php echo $editkudo->kudomsg; ?></textarea></td> </tr> <tr> <td><input type="hidden" value="<?php echo $editkudo->kudoid; ?>" name="kudoid"></td> <td></td> <td></td> </tr> <tr> <td><button type="submit" value="update" class="aciformbutton" name="submit" />Update Kudos</button> <td></td> <td><button type="reset" value="reset" class="aciformbutton">Start Over</button></td> </tr> </table> </form> <?php } acikudos-update.php (here is the problem) Fatal error: Uncaught Error: Call to undefined function add_action() in C:\Program Files (x86)\Ampps\www\wp-content\plugins\advantage-kudos\include\acikudos-update.php on line 112 Error: Call to undefined function add_action() in C:\Program Files (x86)\Ampps\www\wp-content\plugins\advantage-kudos\include\acikudos-update.php on line 112 /** * Handle the request and return the result. */ function acikudos_process_request() { global $wpdb; $errors = array(); // array to hold validation errors $data = array(); // array to pass back data /*Ensure no fields are empty, and if they are, return $errors array encoded in JSON */ if (empty($_POST['kudoagent'])) $errors['kudoagent'] = 'Agent Name is required.'; if (empty($_POST['kudoagentid'])) $errors['kudoagentid'] = 'Agent ID is required.'; if (empty($_POST['agentloc'])) $errors['agentloc'] = 'Agent Location is required.'; if (empty($_POST['kudoclient'])) $errors['kudoclient'] = 'Agent Queue is required.'; if (empty($_POST['kudocust'])) $errors['kudocust'] = 'Customer Name is required.'; if (empty($_POST['kudoacct'])) $errors['kudoacct'] = 'Customer Account # is required'; if (empty($_POST['kudomsg'])) $errors['kudomsg'] = 'Kudo Messge is required'; if (empty($_POST['kudoid'])) $errors['kudoid'] = 'If you see this message contact Intranet Admin or Supervisor with date of posting kudos, tech agents name and your name'; // return a response =========================================================== // if there are any errors in our errors array, return a success boolean of false if ( ! empty($errors)) { // if there are items in our errors array, return those errors $data['success'] = false; $data['errors'] = $errors; } else { // if there are no errors process our form, then return a message /* Set the proper table name to a variable */ $kudotable=acikudos_table_name(); #$table_name = acikudos_table_name(); if (isset($_POST['create'])) { $kudomsg = $_POST['kudomsg']; $kudoagent = $_POST['kudoagent']; $kudoagid = $_POST['kudoagentid']; $kudocust = $_POST['kudocust']; $kudoacct = $_POST['kudoacct']; $kudoclient = $_POST['kudoclient']; $kudoloc = $_POST['agentloc']; $kudoid = $_POST['kudoid']; $wpdb->update( $kudotable, array( 'kudomsg' => $kudomsg, 'kudoagent' => $kudoagent, 'kudoagid' => $kudoagid, 'kudocust' => $kudocust, 'kudoacct' => $kudoacct, 'kudoclient' => $kudoclient, 'kudoloc' => $kudoloc ), array('kudoid' => $kudoid), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' ), array( '%d' ) ); } // show a message of success and provide a true success variable $data['success'] = true; $data['message'] = 'Success!'; } // return all our data to an AJAX call echo json_encode($data); return $data; } /** * AJAX handler for the "ACIKudos" action. */ function acikudos_ajax_handler() { global $wpdb; $data = acikudos_process_request(); header( 'Content-Type: application/json; charset=' . get_bloginfo( 'charset' ) ); echo json_encode( $data ); exit; } add_action( 'wp_ajax_nopriv_acikudos', 'acikudos_ajax_handler' ); <--- Line 112 add_action( 'wp_ajax_acikudos', 'acikudos_ajax_handler' ); kudoform.js file !function( $ ) { // Self-executing function closure, will ensure $ is jQuery - might be running in noConflict mode $( document ).ready( function() { $( "#acikudos-update" ).submit( // Don't bind to all forms, just ours function ( event ) { event.preventDefault(); $('.form-group').removeClass('has-error'); // remove the error class $('.help-block').remove(); // remove the error text var data = $( this ).serializeArray(); // Will automatically grab all form fields and data data.push({ name : "create", value: "1" }); data.push({ name : "action", value: "acikudos" // This parameter needs to match the wp_ajax_* hook. }); $.post( acikudos.ajaxUrl, // Use our JavaScript variable "acikudos" we defined in wp_localize_script() data, // POST data function ( data ) { // Your form handling } ); } ) } ); }( jQuery );
  5. Stripped out the permission section of the script until I get the update issue resolved. Here is the full page: function kudos_edit_new() { global $userdata, $current_user, $wpdb; wp_get_current_user(); //start of update if(isset($_POST['submit'])) { global $wpdb; $tablename=acikudos_table_name(); $kudotable = $tablename; $kudomsg = $_POST['kudomsg']; $kudoagent = $_POST['kudoagent']; $kudoagid = $_POST['kudoagentid']; $kudocust = $_POST['kudocust']; $kudoacct = $_POST['kudoacct']; $kudoclient = $_POST['kudoclient']; $kudoloc = $_POST['agentloc']; $kudoid = $_POST['kudoid']; $wpdb->update( $kudotable, array( 'kudomsg' => $kudomsg, 'kudoagent' => $kudoagent, 'kudoagid' => $kudoagid, 'kudocust' => $kudocust, 'kudoacct' => $kudoacct, 'kudoclient' => $kudoclient, 'kudoloc' => $kudoloc ), array('kudoid' => $kudoid), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' ), array( '%d' ) ); $lastsql = $wpdb->last_query; echo $lastsql; echo "<br />Kudos Updated"; } else { echo "Something went really wrong"; } //end of update $kudoacct = $_GET['acct']; $tablename=acikudos_table_name(); $editkudos = $wpdb->get_results( "SELECT * FROM $tablename WHERE kudoacct = '$kudoacct'"); foreach ( $editkudos as $editkudo ) { ?> <form name="acikudos_form_update" id="updatekudos" method="post" action="" enctype="multipart/form-data"> <table> <tr> <td>Agent Name</td> <td> </td> <td><input name="kudoagent" type="text" value="<?php echo $editkudo->kudoagent; ?>" /></td> </tr> <tr> <td>Agent ID</td> <td></td> <td><input name="kudoagentid" type="text" value="<?php echo $editkudo->kudoagid; ?>" /></td> </tr> <tr> <td>Agent Location</td> <td></td> <td><select name="agentloc" size="1"> <option value="<?php echo $editkudo->kudoloc; ?>"><?php echo $editkudo->kudoloc; ?></option> <option value="Amherst Center">Amherst Center</option> <option value="Charlottetown Center">Charlottetown Center</option> <option value="Kingston Center">Kingston Center</option> </select></td> </tr> <tr> <td>Agent Queue</td> <td></td> <td><select name="kudoclient" size="1"> <option value="<?php echo $editkudo->kudoclient; ?>"><?php echo $editkudo->kudoclient; ?>"</option> <option value="AR">AR</option> <option value="Tech Support">Tech Support</option> <option value="PNI">PNI</option> </select></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td>Customer Name</td> <td></td> <td><input name="kudocust" type="text" value="<?php echo $editkudo->kudocust; ?>"/></td> </tr> <tr> <td>Customer Account #</td> <td></td> <td><input name="kudoacct" type="text" value=" <?php echo $kudoacct; ?>" /></td> </tr> <tr> <td>Kudos</td> <td></td> <td><textarea cols="50" name="kudomsg" rows="5"><?php echo $editkudo->kudomsg; ?></textarea></td> </tr> <tr> <td><input type="hidden" value="<?php echo $editkudo->kudoid; ?>" name="kudoid"></td> <td></td> <td></td> </tr> <tr> <td><button type="submit" value="submit" class="aciformbutton" name="submit" />Update Kudos</button> <td></td> <td><button type="reset" value="reset" class="aciformbutton">Start Over</button></td> </tr> </table> </form> <?php } } This is what I get when I submit: SHOW FULL COLUMNS FROM `wpl2_acikudos` Kudos Updated
  6. I run $wpdb->last_query; but getting SHOW FULL COLUMNS FROM `wpl2_acikudos` instead of the update
  7. Trying to update to database but not updating an not getting any errors. The info is posting but not sure why not updating. if (!empty($_POST)) { global $wpdb; $table = $tablename; $kudomsg = $_POST['kudomsg']; $kudoagent = $_POST['kudoagent']; $kudoagid = $_POST['kudoagentid']; $kudocust = $_POST['kudocust']; $kudoacct = $_POST['kudoacct']; $kudoclient = $_POST['kudoclient']; $kudoloc = $_POST['agentloc']; $data = array( 'kudomsg' => $kudomsg, 'kudoagent' => $kudoagent, 'kudoagid' => $kudoagid, 'kudocust' => $kudocust, 'kudoacct' => $kudoacct, 'kudoclient' => $kudoclient, 'kudoloc' => $kudoloc ); $where = array('kudoid' => $_POST['kudoid']); $success=$wpdb->update($table , $data, $where); if($success){ echo "Kudos has been updated. Go to Kudos page to view"; echo "<br /><a href='" .$kudourl."'>Close</a>"; } } else { $kudoacct = $_GET['acct']; $tablename=acikudos_table_name(); $editkudos = $wpdb->get_results( "SELECT * FROM $tablename WHERE kudoacct = '$kudoacct'"); foreach ( $editkudos as $editkudo ) { ?> <form name="acikudos_form" id="updatekudos" method="post" action="" enctype="multipart/form-data"> <table> <tr> <td>Agent Name</td> <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <td><input name="kudoagent" type="text" value="<?php echo $editkudo->kudoagent; ?>" /></td> </tr> <tr> <td>Agent ID</td> <td></td> <td><input name="kudoagentid" type="text" value="<?php echo $editkudo->kudoagid; ?>" /></td> </tr> <tr> <td>Agent Location</td> <td></td> <td><select name="agentloc" size="1"> <option value="<?php echo $editkudo->kudoloc; ?>"><?php echo $editkudo->kudoloc; ?></option> <option value="Amherst Center">Amherst Center</option> <option value="Charlottetown Center">Charlottetown Center</option> <option value="Kingston Center">Kingston Center</option> </select></td> </tr> <tr> <td>Agent Queue</td> <td></td> <td><select name="kudoclient" size="1"> <option value="<?php echo $editkudo->kudoclient; ?>"><?php echo $editkudo->kudoclient; ?>"</option> <option value="AR">AR</option> <option value="Eastlink Tech Support">Eastlink Tech Support</option> <option value="PNI">PNI</option> </select></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td>Customer Name</td> <td></td> <td><input name="kudocust" type="text" value="<?php echo $editkudo->kudocust; ?>"/></td> </tr> <tr> <td>Customer Account #</td> <td></td> <td><input name="kudoacct" type="text" value=" <?php echo $kudoacct; ?>" /></td> </tr> <tr> <td>Kudos</td> <td></td> <td><textarea cols="50" name="kudomsg" rows="5"><?php echo $editkudo->kudomsg; ?></textarea></td> </tr> <tr> <td><input type="hidden" value="<?php echo $editkudo->kudoid; ?>" name="kudoid"></td> <td></td> <td></td> </tr> <tr> <td><button type="submit" value="sendkudos" class="aciformbutton" name="sendkudos" />Update Kudos</button> <td></td> <td><button type="reset" value="reset" class="aciformbutton">Start Over</button></td> </tr> </table> </form>
  8. This is off the original topic I started but I am running in to a new issue. "Update" I can post and delete but having a problem updating. I am getting no errors showing just white screen. I have verified that everything is posting but the database is not updating for some reason. Not sure if it is late and I am not seeing straight or I actually messed something up that I can not see yes I probably could have put the _POST in the array but they are outside for testing purposes.: if (!empty($_POST)) { global $wpdb; $table = $tablename; $kudomsg = $_POST['kudomsg']; $kudoagent = $_POST['kudoagent']; $kudoagid = $_POST['kudoagentid']; $kudocust = $_POST['kudocust']; $kudoacct = $_POST['kudoacct']; $kudoclient = $_POST['kudoclient']; $kudoloc = $_POST['agentloc']; $data = array( 'kudomsg' => $kudomsg, 'kudoagent' => $kudoagent, 'kudoagid' => $kudoagid, 'kudocust' => $kudocust, 'kudoacct' => $kudoacct, 'kudoclient' => $kudoclient, 'kudoloc' => $kudoloc ); $where = array('kudoid' => $_POST['kudoid']); $success=$wpdb->update($table , $data, $where); if($success){ echo "Kudos has been updated. Go to Kudos page to view"; echo "<br /><a href='" .$kudourl."'>Close</a>"; } } else { $kudoacct = $_GET['acct']; $tablename=acikudos_table_name(); $editkudos = $wpdb->get_results( "SELECT * FROM $tablename WHERE kudoacct = '$kudoacct'"); foreach ( $editkudos as $editkudo ) { ?> <form name="acikudos_form" id="updatekudos" method="post" action="" enctype="multipart/form-data"> <table> <tr> <td>Agent Name</td> <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <td><input name="kudoagent" type="text" value="<?php echo $editkudo->kudoagent; ?>" /></td> </tr> <tr> <td>Agent ID</td> <td></td> <td><input name="kudoagentid" type="text" value="<?php echo $editkudo->kudoagid; ?>" /></td> </tr> <tr> <td>Agent Location</td> <td></td> <td><select name="agentloc" size="1"> <option value="<?php echo $editkudo->kudoloc; ?>"><?php echo $editkudo->kudoloc; ?></option> <option value="Amherst Center">Amherst Center</option> <option value="Charlottetown Center">Charlottetown Center</option> <option value="Kingston Center">Kingston Center</option> </select></td> </tr> <tr> <td>Agent Queue</td> <td></td> <td><select name="kudoclient" size="1"> <option value="<?php echo $editkudo->kudoclient; ?>"><?php echo $editkudo->kudoclient; ?>"</option> <option value="AR">AR</option> <option value="Eastlink Tech Support">Eastlink Tech Support</option> <option value="PNI">PNI</option> </select></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td>Customer Name</td> <td></td> <td><input name="kudocust" type="text" value="<?php echo $editkudo->kudocust; ?>"/></td> </tr> <tr> <td>Customer Account #</td> <td></td> <td><input name="kudoacct" type="text" value=" <?php echo $kudoacct; ?>" /></td> </tr> <tr> <td>Kudos</td> <td></td> <td><textarea cols="50" name="kudomsg" rows="5"><?php echo $editkudo->kudomsg; ?></textarea></td> </tr> <tr> <td><input type="hidden" value="<?php echo $editkudo->kudoid; ?>" name="kudoid"></td> <td></td> <td></td> </tr> <tr> <td><button type="submit" value="sendkudos" class="aciformbutton" name="sendkudos" />Update Kudos</button> <td></td> <td><button type="reset" value="reset" class="aciformbutton">Start Over</button></td> </tr> </table> </form> This is a list of my columns kudoid kudomsg kudoagent kudoagid kudocust kudoacct kudoclient kudoloc kudoentry kudoadmin kudopic kudostatus
  9. Honestly maxxd never even thought of going that route. Thank you that fixed the problem. ref the error reporting. the wp_debug is on which is allowing me to catch most errors that are happening (which is lots..lol) but some are still slipping through. I might just go back to the error_reporting as I am use to that. This is my first time making a plugin for wordpress so still learning, thank you for your help.
  10. Here is the issue I am having, as you see with the above code I got part of what I need done. What the problem I am having now is: if $url with ?viewkudoid=XX - This works to show the kudo with the id of whatever if $url without the $?viewkudoid - This works to show all the kudos if $url with ?viewkudoid= (without the xx) - This shows a blank page without even a page title (wordpress) I have part 1 and 2 working, now sure how to implement 3. Any help would be greatly appreciated.
  11. Getting closed got everything working but the $viewkudosid=(blank) getting blank page with no errors. Trying to figure out where to have it echo No Kudos in Database $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $url = $actual_link; if (strpos($url, "?viewkudoid")!==false){ $viewkudoid = $_GET['viewkudoid']; $tablename=acikudos_table_name(); $showkudos = $wpdb->get_results( "SELECT * FROM $tablename WHERE kudoid = '$viewkudoid'"); foreach ( $showkudos as $kudo ) { echo "<blockquote class=\"otro-blockquote\">"; echo $kudo->kudomsg; echo "<span>"; echo "<b>Kudos for:</b> " .$kudo->kudoagent. ", " .$kudo->kudoloc; echo "<br>By: ".$kudo->kudocust. ", " . date("F j, Y g:i a", strtotime($kudo->kudoentry));; echo "</span></blockquote>"; } } else { $tablename=acikudos_table_name(); $showkudosall = $wpdb->get_results( "SELECT * FROM $tablename order by kudoentry desc"); foreach ( $showkudosall as $allkudo) { echo "<blockquote class=\"otro-blockquote\">"; echo $allkudo->kudomsg; echo "<span>"; echo "<b>Kudos for:</b> " .$allkudo->kudoagent. ", " .$allkudo->kudoloc; echo "<br>By: ".$allkudo->kudocust. ", " . date("F j, Y g:i a", strtotime($allkudo->kudoentry));; echo "</span></blockquote>"; echo "<hr>"; } } }
  12. New brain headache for myself. When I use this: http://127.0.0.1/kudos/?viewkudoid= or this http://127.0.0.1/kudos/?viewkudoid=xxx The code works. I know I am missing a piece of code somewhere, done lots of searching to see how to go about doing it and was looking for a push from somebody to point me in the right direction ie with a link to an example if possible. Problem is when i use this: http://127.0.0.1/kudos/ i get an error. Working code with first 2 urls: $viewkudoid = $_GET['viewkudoid']; $tablename=acikudos_table_name(); $showkudos = $wpdb->get_results( "SELECT * FROM $tablename WHERE kudoid = '$viewkudoid'"); $showkudosall = $wpdb->get_results( "SELECT * FROM $tablename order by kudoentry desc"); // Query to fetch data from database table and storing in $showkudosall if ( $showkudos ) { foreach ( $showkudos as $kudo ) { echo $kudo->kudoagent; } } elseif ( $showkudosall ) { foreach ( $showkudosall as $allkudo) { echo "<blockquote class=\"otro-blockquote\">"; echo $allkudo->kudomsg; echo "<span>"; echo "<b>Kudos for:</b> " .$allkudo->kudoagent. ", " .$allkudo->kudoloc; echo "<br>By: ".$allkudo->kudocust. ", " . date("F j, Y g:i a", strtotime($allkudo->kudoentry));; echo "</span></blockquote>"; echo "<hr>"; } } else { echo "No Kudos In Database"; } What I am getting with the last url without the ?viewkudosid- Notice: Undefined index: viewkudoid in C:\Program Files (x86)\Ampps\www\wp-content\plugins\advantage-kudos\include\acikudos-view.php on line 6 Line 6: $viewkudoid = $_GET['viewkudoid'];
  13. Hey maxxd. The plugin is actually going to be used for a couple of companies where they would like to keep the posts separate. Yeah I know it would save a lot of headaches. The acikudos_table_name() is for now a function: function acikudos_table_name(){ global $table_prefix, $wpdb; $table_name = $wpdb->prefix . 'acikudos'; return $table_name; } The table name is going to be changed probably within the week (once i get around to change it...lol) There is also going to be other functions included in the kudos program that is going to be k i s s for the companies that will be using it.
  14. This is still me but thanks to Gizmola I got my account back. Well on a good note I am a little farther ahead. Thanks Guys got a working part ver of 1/100 of my program...lol function show_kudos() { global $wpdb; $tablename = acikudos_table_name(); $results = $wpdb->get_results( "SELECT * FROM $tablename order by kudoentry desc"); // Query to fetch data from database table and storing in $results if(!empty($results)) { foreach($results as $row){ echo $row->kudoagent; } } }
  15. stupid me figured out the problem. I had count($hauntcount) when it was suppose to be count($rowhsr)
  16. doesn't matter if it is before or after the query, still getting the same result
  17. trying to see what the result is
  18. ok, got a new error: Notice: Trying to get property of non-object in \www\wp-content\plugins\addysearch\index.php on line 101 string(12) "815 pembroke" We found 0 results. Line 100: $rowhsr = $wpdb->get_results( "SELECT * FROM locations where stname like '%" . $houseaddy ."%'"); Line 101: $hauntcount = $rowhsr->num_rows; Line 102: var_dump($houseaddy);
  19. Tried another search and got same result string(17) "121 mount whatley"
  20. This is the result string(17) "my address" which is what was searched for and the proper information is displayed from the search
  21. Thanks Ch0cu3r but not sure what the issue is: When somebody puts in for example: My Address In the database is 123 My Address Street houseaddy = My Address stname = 123 My Address Street count is coming up = 0
  22. Is it possible to count query rows and display query, tried a number of things but can't get row count: $rowhsr = $wpdb->get_results( "SELECT * FROM locations where stname like '%" . $houseaddy ."%'"); $hauntcount = $rowhsr->num_rows; echo 'Number of entries found:' . $hauntcount; foreach ( $rowhsr as $rowhsr ) { echo $rowhsr->stname }
  23. Awesome, just what I was looking for thank you very much
  24. Perfect thank you, that fixed one problem but caused another. Now when box is empty goes to else { echo "0 entries available"; but when somebody enters an entry that does not exist just shows blank. Is there a way to combine if (!empty($rowhs)) { with if(trim($_POST["haddy"]) != "") { to show else { echo "0 entries available";
  25. I am having a problem when a user just hits submit on an empty field and having all entries displayed. Is there a way to stop this with the code I have and go right to the else { if ( isset( $_POST['hp-submitted'] ) ) { // sanitize form values $houseaddy = sanitize_text_field( $_POST["haddy"] ); global $wpdb; #$results = $GLOBALS['wpdb']->get_results("SELECT * FROM locations where stname='$houseaddy'"); $rowhs = $wpdb->get_results( "SELECT * FROM locations where stname like '%" . $houseaddy ."%'"); if (!empty($rowhs)) { foreach ( $rowhs as $rowhs ) { echo "<br />"; echo "<p><b><font color=\"#92AEFE\" size=\"4\">Report Address: </font><font size=\"4\">"; echo $rowhs->stname . ", " . $rowhs->hcity ." ". $rowhs->hprov . "</font></b><br>"; echo "<b><font size=\"4\" color=\"#92AEFE\">Report Number: </font><font size=\"4\">" . $rowhs->hid ."</font></b><br>"; echo "<b><font size=\"4\" color=\"#92AEFE\">Date of Report: </font><font size=\"4\">" . $rowhs->datepost ."</font></b></p>"; } } else { echo "0 entries available"; echo "<br /><br />"; } }
×
×
  • 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.