Jump to content

aikorei

Members
  • Posts

    29
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://trentbooks.com

Profile Information

  • Gender
    Male
  • Location
    Seattle, WA

aikorei's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. I just realized that my php errors were printing to an error_log I didn't realize I had (in a different folder than the main error_log I usually check). There was a syntax error that was blocking the file from loading right. I had been trying to echo something to the page, and it wasn't working...now it is. I guess the right syntax makes a difference. =P Thanks for the help anyhow!
  2. I'll throw you all a softball, since I'm sure this has to be easy and I'm just daft... All I'm trying to do is create an html form that posts data to a php file on my server. But the php file isn't a webpage. It's just a file in one of my subfolders. When I put what I believe the absolute url to the file on my server in as the action, it brings me to a blank white page and nothing happens. I believe I get the concept of using $_POST to get the information and handle it....but how do I get it to the file?
  3. I just realized there was a syntax error on my part. get_var works, I just can't use it with query() [duh]. This syntax worked: $app_count = $wpdb->get_var("SELECT COUNT(worker) FROM $app_table WHERE worker = $user_id AND status = 'completed' "); Thanks very much for the help. I really do appreciate your time. =)
  4. I wish I knew. All I know is that it's a global variable and that whenever I need to interact with a table I need to use the syntax I've used above. Unfortunately, I'm only going on about 3 or 4 weeks of actually diving into code to significantly modify my site. As an alternative approach, I tried to use get_results(), as follows: $sql = $wpdb->get_results("SELECT COUNT(worker) FROM $app_table WHERE worker = $user_id AND status = 'completed' "); This resulted in: int(0) int(0) from var_dump(). I found this site, which has been somewhat helpful in syntax, but doesn't explain the deeper details of what's happening with $wpdb or the other WP functions: http://wp.smashingmagazine.com/2011/09/21/interacting-with-the-wordpress-database/
  5. 3.5.1. I'm still not finding much either, and unfortunately all the sites I've found for running any standard SQL query in WP do so using wpdb->query().
  6. Sorry. The query() code is buried somewhere in WordPress, and I'm not finding the actual code online yet. What I did find, however, is this snippet from WordPress.org: I didn't realize it was used in this way (true/false). It looks like I may need to find another way to pull this value through.
  7. When I enter $test = $wpdb->query(); echo(var_dump($test)); the output is bool(false) bool(false)
  8. I created a function to count a number of appointments in my database: function bp_core_get_user_appointments( $user_id ) { global $wpdb; // Finds the total number of appointments a user has completed. if ( !$app_count_cached = wp_cache_get( '$app_count_cached_' . $user_id, 'bp') ) { $app_table = $wpdb->prefix . 'app_appointments'; $sql = $wpdb->prepare("SELECT COUNT(worker) FROM $app_table WHERE worker = $user_id AND status = 'completed' "); $app_count = $wpdb->query($sql); $app_count_cached = wp_cache_set( '$app_count_cached_' . $user_id, $app_count, 'bp', 86400); return $app_count; } else { $app_count = wp_cache_get( '$app_count_cached_' . $user_id, 'bp'); return $app_count; } } I then call this within another function thusly: $app_count = bp_core_get_user_appointments( $user_id ); if ( $app_count ) { $fullname .= ' [' . $app_count . ']'; } When I run the above SQL query in phpMyAdmin (modified slightly so it grabs the right table and everything), it produces the correct count. When it populates on my pages, however, it simply displays as: "[1]" This is regardless of how many actual appointments there are, so I'm guessing it's simply being pulled through somewhere as a boolean, i.e. "True - there are appointments here to count". But I'm not sure why. Where did I go wrong here?
  9. Ah. That's the first I'd heard of that. I read somewhere that single quotes and double quotes were identical, but they apparently left out that piece of information. Thanks for the help (again)!! I really appreciate it. It works now. =)
  10. This is probably a no-brainer, but I'm just not seeing where the problem lies. I've written two pieces of .php for a WordPress site, one copied from the other. One works, one doesn't. The piece that works is: $k_user_id = $current_user->ID; $k_table = $wpdb->prefix . 'bp_friends'; $k_friends1 = $wpdb->get_col( "SELECT initiator_user_id FROM $k_table WHERE friend_user_id = $k_user_id AND is_confirmed = 1" ); The piece that doesn't is: $app_table = $wpdb->prefix . 'app_appointments'; $sql = $wpdb->prepare('SELECT COUNT(worker) FROM $app_table WHERE worker = $user_id AND status = "completed" '); $app_count = $wpdb->query($sql) The error that's populating in my error log for the second statement is: WordPress database error Table 'my_table.$app_table' doesn't exist for query It appears that the actual variable "$app_table" is getting passed through to the database instead of the variable's value, "app_appointments". Can anyone point where I'm going wrong here? Thanks.
  11. The confirmation <div> is already assigned to .click()... if I assign another jQuery piece to the same .click() action, wouldn't they both fire at the same time?
  12. I'm not sure if this is the right place for this, but since php is sort of the hub I figure this might work. I'm struggling with finding the right way to snag a variable from a javascript prompt and pass that through to the server for a mysql query. I'm relatively new to all of this, so any help (even the obvious stuff) would be greatly appreciated. Here's my situation... I'm using a scheduling plugin on Wordpress that allows users to schedule an appointment with a service provider. Unfortunately, these appointments are for a set duration (e.g. 30 minutes). I'd like to allow the user to select their start time and then set their own duration. The plugin uses jQuery to display a calendar in table format and the user can click on a date/time that works for them. Then a new <div> appears on the page to confirm the appointment. I would basically like to insert a javascript prompt when the user clicks on their starting time that asks for the duration in hours. I need to pass this value back to the server (using jQuery or Ajax I'm guessing?) so I can send a query to the database and check if this time conflicts with other appointments, then continue with the confirmation <div>. I've spent probably 2 or 3 hours searching Google and I'm simply not finding a way to do this. Seems like it should be straightforward, but the answer is eluding me.
  13. Ah. I'm guessing that's my problem. Me <-- noob Thanks.
  14. I used that query three times and got the following results: SELECT `end`, DATE_ADD(`end`, INTERVAL 30 MINUTE) FROM `oyuvfn_app_appointments` WHERE `ID` = 3 2013-02-13 17:00:00 2013-02-13 17:30:00 SELECT `end`, DATE_ADD(`end`, INTERVAL 20 MINUTE) FROM `oyuvfn_app_appointments` WHERE `ID` = 3 2013-02-13 17:00:00 2013-02-13 17:20:00 SELECT `end`, DATE_ADD(`end`, INTERVAL 2 HOUR) FROM `oyuvfn_app_appointments` WHERE `ID` = 3 2013-02-13 17:00:00 2013-02-13 19:00:00 It seems as though the new value is being calculated correctly, but it's not replacing the old value. All of those values populated 17:00:00 as the start value...? Edit: Perhaps I was only assuming DATE_ADD actually updates the cell...do I need to actually use UPDATE here? Also, this still doesn't explain what was happening earlier on. That was just weird (though I'm will to admit there may have been some operator error in there somewhere).
×
×
  • 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.