Jump to content

LDMartin1959

Members
  • Posts

    22
  • Joined

  • Last visited

LDMartin1959's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. That still causes the content to disappear entirely. Which suggests that the query is not returning any results, yet I know it is (at least, at some point) because when the content IS being generated it is coming from the values from the query.
  2. I restore the code back to the original configuration and added a line to simply echo the value in mysql_num_rows($ql) after if ($q1) to see what it contains. Simply adding that echo killed the display of the intended content from everywhere, where intended and not; when I removed that echo the content returned as before (complete where intended, partial display where not intended to display any). I did an assignment $test_q1 = mysql_num_rows($ql) which also killed the display of the intended content from everywhere, where intended and not; when I removed that echo the content returned as before (complete where intended, partial display where not intended to display any). I'm not sure what I misunderstood of your instruction but obviously I need additional clarification.
  3. Whoops. I musta done something wrong: I replaced $row_diamond=mysql_fetch_object($q1); if ($q1){ with if (mysql_num_rows($ql) != 0){ $row_diamond=mysql_fetch_object($q1); The result was that the content is no longer showing up on the page it is supposed, the page which fulfills the criteria. Did I replace too much?
  4. I am a WP and PHP novice still flailing in the deep end of the pool. I am trying to add some logic to display content on certain pages (via WP templates), not on others. I've made some progress but having issues. Here is the plan: On certain pages with an post type of "EVENT" I want content to appear, but not on OTHER pages with an post type of "EVENT". The problem I am running into is that part of the content is appearing on ALL event pages even if they don't meet the criteria. The logic is intended to be this: If the page is post_type "EVENT", AND if the indicated table contains a field with a record CAT which matches the current "POST ID", AND contains a record TYPE which matches value "1", display table cells which contain text "Presented by: ", an href and an image, else display table cells which contain a nonbreaking space. The problem is that the text "Presented by: " is appearing on ALL the even pages, regardless of whether they meet the criteria or not -- which would tend to indicate a problem with the logic code -- but by the same token the href and image are correctly appearing ONLY on the pages that meet the criteria and are NOT appearing on along with the rogue text on pages which do not meet the criteria. I am sure it is a coding error on my part but I am not sure what. ANY help anyone could give would be GREATLY appreciated. The code involved is below (oh, and I should mention that the code in question is in the HEADER.PHP file): <?php if($post->post_type=='event') { $q1=mysql_query("SELECT * FROM table_name WHERE type = 1 AND cat = $post->ID "); $row_diamond=mysql_fetch_object($q1); if ($q1){ ?> <td width="115" align="right" valign="middle" id="diamond1"><strong style="position:relative;bottom:-25px;">Presented by: </strong></td> <td id="diamond2" width="190"> <a href="<?=$row_diamond->website?>" title="<?=$row_diamond->website_title?>" target="_blank" style="cursor:pointer;"><img style="position:relative;bottom:5px;" src="<?php bloginfo('siteurl'); ?>/wp-content/plugins/sean_event/files/<?=$row_diamond->image?>" alt="<?=$row_diamond->alt_text?>"border="0"></a> <br /> </td> <?php } else{ ?> <td width="115" align="right" valign="middle" id="diamond1"> </td> <td id="diamond2" width="190"> </td> <?php } } ?>
  5. You'd think when you use the MySQL query function to create the query it'd be smart enough not to do that!! Thanks. That solves that problem.
  6. Working on a WordPress site. I've been again thrown into the deep end of the pool on this. I am trying to add some code to the HEADER.PHP file which will display content under certian conditions. Here's the code in question: $q1=mysql_query("SELECT * FROM 'wp_sean_sponsors' WHERE 'type' LIKE 1 AND 'cat'='.$post->ID.' "); $row_diamond=mysql_fetch_object($q1); if ($q1){ ?> The problem is that there doesn't seem to be anything coming back from the database. When I do a var_dump of $q1 it comes back as boolen(false), which I am taking to mean it has no value. But I know that a record which matches the criteria exists. I tried replacing '.$post->ID.' with a hard value with no change. I've got no clue where to go next but they're beating me until I come up with a solution.
  7. Well, I just got thrown into this after the mess was made. I had nothing to do with creating it!!
  8. No, wasn't intentional (although in terms of the logic result, it shouldn't make any difference as far as I can tell since the full statement still returns true). I am working on adding this logic to several WordPress templates on this site and apparently different people coded not only different pages but different portions of the pages and there are a LOT of inconsistencies in how things are done from page to page, and section to section. So that was my error for not getting all the changes made in that location. But I'm still not seeing any change in behaviour even with the correction. Frankly, there are tons of issues with this site: on a totally unrelated issue, the site has two different contact form which submit information via the mail() function, but one of them doesn't work despite the fact that PHP returns true from the function (which should mean that PHP successfully submitted the data) on both, the fact that both are in the same directory and both files are set to the same Unix permissions levels, since the one works it shouldn't be a PHP.ini setting and the one that failed simply stopped working one day even though no one touched the file or (as far as I can tell) any of the supporting files. Ugggh. This is probably not the best site for someone with my lack of PHP experience to be "gaining experience" with.
  9. I echoed the values to the screen and those are the values it gave back (edited, as I said). The echo code is: echo "Start Time: " . $str . "<br />"; echo "Online Reg Close: " . $close_reg . "<br />"; echo "AutoClose: " . $auto_close_reg . "<br />"; echo "Current Time: " . $time_now . "<br />"; echo "Post register: " . ($post->register) . "<br />"; The returned values are (as of the time of testing): Start Time: 1386266400 Online Reg Close: 1386201600 AutoClose: 1386277140 Current Time: 1386270164 Post register: 0 Unless my eyes are deceiving me (and I'll grant that's a possibility), these values still fulfill the second if statement as true.
  10. Correct, which means the second if statement should be true (at least, if I did my logic correctly): IF $str is less than $time_now [true] AND (($row->register=="0") [it is not] OR ($auto_close_reg is less than $time_now) [it is, thus making the OR clause true]) then echo $reg_closed_message
  11. I have the following code: <?php if(($time_now<$str) && (($post->register=="0") || ($close_reg<$time_now))) { echo $online_reg_closed_message; } else if(($str<$time_now) && (($row->register=="0") || ($auto_close_reg<$time_now))) { echo $reg_closed_message; } else { echo $final_message; } ?> I checked the values of the variables and they come back as this (shortened to significant values only for clarity: $auto_close_reg 84340 $time_now 70164 (at the time of testing, at any rate) $str 66400 $close_reg 16000 $post->register 0 Now, if the logic is functioning correctly I should (at the time of testing) be seeing the message stored in$reg_closed_message displayed. I'm not. I'm seeing $final_message. It's probably something obvious but I can't see it. What did I do wrong here? Thank you.
  12. I've sorta narrowed the problem to the table that begins at about line 97. I've eliminated the entire contents of the table and left it with two cells in a single row and THAT seems to be enough to break the PHP when enclosed with the else{}, yet the OTHER table doesn't give any problem when surrounded by the else{} statement. What am I missing?
×
×
  • 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.