Forum Replies Created

Viewing 15 replies - 196 through 210 (of 226 total)
  • Thread Starter Jim R

    (@jim-r)

    Since I see your name dotted around the forum providing good solutions, any idea why the code above would make widgets disappear from the sidebar? It has something to do with the select_mysql_db command. I even tried closing the connection, but that didn’t work either…unless I’m not closing it properly.

    I’m having the same problem. With me it has something to do with my database select code, which is the second line of code in the following:

    <?php
     $wp_tagID = get_query_var('tag_id');  
    
    mysql_select_db("jwrbloom_hhr");
    
    $query = 'SELECT * FROM playerRank';
    $results = mysql_query($query);
    while($line = mysql_fetch_assoc($results)) {
    
    if ($line['wpID'] == $wp_tagID)  {
    
    	echo '<div class="player">';
    	echo '<div>' . $line['nameFirst'] . ' ' . $line['nameLast'] . '</div>';
    	echo '<div><strong>' . $line['height'] . ' ';
    		if ($line['position'] == 'PG')  {echo 'Point Guard';}
    		elseif ($line['position'] == 'SG')  {echo 'Shooting Guard';}
    		elseif ($line['position'] == 'SF')  {echo 'Small Forward';}
    		elseif ($line['position'] == 'PF')  {echo 'Power Forward';}
    		elseif ($line['position'] == 'C')  {echo 'Center';}
    		echo '</strong></div>';
    	echo '<div><strong>' . $line['hschool'] . '</strong></div>';
    
    	echo '<div><img src="/wp-content/uploads/' . $line['nameLast'] . $line['nameFirst'] . '.jpg" width=150 height=200></div>
    
    	</div>';
    }
    
    }
    ?>

    I’m having problems with disappearing Widgets too. It started while I was using the PHP Code Wdiget plugin, but I’m not sure it has much to do with that Widget. I’m pretty sure it has more to do with what is in the custom PHP code.

    Example…here is a code I’m using to carry profile information to Tag Archive pages:

    <?php
     $wp_tagID = get_query_var('tag_id');  
    
    mysql_select_db("jwrbloom_hhr");
    
    $query = 'SELECT * FROM playerRank';
    $results = mysql_query($query);
    while($line = mysql_fetch_assoc($results)) {
    
    if ($line['wpID'] == $wp_tagID)  {
    
    	echo '<div class="player">';
    	echo '<div>' . $line['nameFirst'] . ' ' . $line['nameLast'] . '</div>';
    	echo '<div><strong>' . $line['height'] . ' ';
    		if ($line['position'] == 'PG')  {echo 'Point Guard';}
    		elseif ($line['position'] == 'SG')  {echo 'Shooting Guard';}
    		elseif ($line['position'] == 'SF')  {echo 'Small Forward';}
    		elseif ($line['position'] == 'PF')  {echo 'Power Forward';}
    		elseif ($line['position'] == 'C')  {echo 'Center';}
    		echo '</strong></div>';
    	echo '<div><strong>' . $line['hschool'] . '</strong></div>';
    
    	echo '<div><img src="/wp-content/uploads/' . $line['nameLast'] . $line['nameFirst'] . '.jpg" width=150 height=200></div>
    
    	</div>';
    }
    
    }
    ?>

    The line that causes all of my widgets to disappear is the second line of my PHP code:

    mysql_select_db(“jwrbloom_hhr”);

    I’ve tried a couple of other options, but then my code doesn’t work.

    Use the plugin Widget Logic. It’s the most flexible because it provides a blank in each Widget where you can put a conditional tag. Anyone from determining if a User is logged in to what Post, Page or Category you’re viewing.

    Another one to try, which isn’t as flexible but a little easier to use is Widget Context. That gives you check boxes for types of Pages, and it allows you to put specific Pages and Posts where you can either only show the widget or only hide it.

    Thread Starter Jim R

    (@jim-r)

    Figured it out. I didn’t have the double == in my “IF” statement, and I hadn’t close my while or if loops.

    <?php
    $wp_tagID = get_query_var(‘tag_id’);

    mysql_select_db(“jwrbloom_hhr”);

    $query = ‘SELECT * FROM playerRank’;
    $results = mysql_query($query);
    while($line = mysql_fetch_assoc($results)) {

    if ($line[‘wpID’] == $wp_tagID) {

    echo ‘<div>’ . $line[‘nameFirst’] . ‘ ‘ . $line[‘nameLast’] . ‘</div>’;
    }

    }
    ?>

    Thread Starter Jim R

    (@jim-r)

    BTW…the result in the PHP widget block is basically nothing, just blank.

    Thread Starter Jim R

    (@jim-r)

    Take a look at this. When I echo out $wp_tagID, which is defined in the first line of the PHP code, it outputs the correct value. There is a corresponding ID in my playerRank table, and it should be echo’ing information from the one that matches.

    I’m putting this code in a PHP widget block.

    <?php
     $wp_tagID = get_query_var('tag_id');  
    
    mysql_select_db("jwrbloom_hhr");
    
    $query = 'SELECT * FROM playerRank';
    $results = mysql_query($query);
    while($line = mysql_fetch_assoc($results)) {
    
    if ($line['wpID'] = $wp_tagID)  {
    
    	echo '<div>' . $line['nameFirst'] . ' ' . $line['nameLast'] . '</div>';
    
     ?>
    Thread Starter Jim R

    (@jim-r)

    @t31os_,

    The second one isn’t working, and I’m guessing that’s the one I need since I need to do more than echo it. I’m using it in a PHP block widget, and it makes my other code not work. It’s just:

    echo 'Just testing...';

    The $wp-query makes it disappear.

    Regarding the first option, would I assign a string variable to that result so I could use it later?

    $ID = get_query_var(‘tag_id’);

    Still, very helpful. I feel like I’m getting closer, and once I can carry that value over, the rest, for me at least, is easy.

    Thread Starter Jim R

    (@jim-r)

    Dang it, I knew my request was too simple, trying to avoid a double post. I need to get the Tag ID passed through after clicking on the Tag’s link. So I click on siteURL.com/tag/tag1_tag2, and it takes me to an Archive.php. I need to get the ID of that Tag so I can use it for something else to put on that Archive.php along with the other content.

    Thread Starter Jim R

    (@jim-r)

    I want to take the $tag_id and associate it with information in another table. Keep in mind, at this stage, I’m manually copying the $tag_id from my WordPress table to my custom table. Again, in my custom table, it’s about a player (his name, school, grade, height, etc), while my Tags in WP are player names, school names, class (2010, 2011, etc) and other keywords. That means not all my $tag_id are useful to me in my custom table.

    So let’s go back to the User clicking on a Tag link. It passes the User to the Archive.php page template with the URL of https://www.hoosierhoopsreport.com/tags/firstWord_secondWord. The actual ID isn’t passed via the URL. Is it still there for me to use?

    Where does one go to see settings? I’ve installed Alkiva, and I have no Admin options to make changes.

    Thread Starter Jim R

    (@jim-r)

    Yeah…I figured it out around 3am.

    Thread Starter Jim R

    (@jim-r)

    BTW…the URL it’s at now is hoosierhoopsreport.com. Long story, but that is my root directory.

    Thread Starter Jim R

    (@jim-r)

    That error is gone. Now I’m trying to reinstall over an existing database. The homepage is just blank. I tried installing over a fresh database, then copying the old database into it. Same result.

    Thread Starter Jim R

    (@jim-r)

    My ISP can’t even get this thing to install properly.

    What is going on????

Viewing 15 replies - 196 through 210 (of 226 total)