Jump to content
Larry Ullman's Book Forums

bobafifi

Members
  • Content count

    14
  • Joined

  • Last visited

  • Days Won

    1

bobafifi last won the day on November 21 2011

bobafifi had the most liked content!

Community Reputation

1 Neutral

About bobafifi

  • Rank
    Newbie
  1. Hi Larry, I agree - the sort order shouldn't constitute duplicate pages as there really is no new content being generated, just the same stuff rearranged. However for some reason, Google thinks differently. Maybe because the URL changes slightly, that's all it takes. They can't be sure if it's a new page or not, so they just go with new page? -Bob
  2. Got it! <?php if (false !== strpos($_SERVER['REQUEST_URI'], 'lna')) { echo 'A-Z'; } ?>
  3. OK - I got something working (not ideal). Made a new variable: <?php $pageTitle = "$_SERVER[REQUEST_URI]"; ?> and then in the title tags <title>Example <?php echo $pageTitle ; ?></title> Depending on the sort order, would like to change $pageTitle to echo different text, for example "A-Z" or "Z-A" (instead of /example.php?sort=lnd), but at least this prints unique page titles.
  4. Hi Larry, Google Webmaster tools is flagging this script for making duplicate page titles. Can you please tell me how best to append/echo the sort order to the page Title in the HTML (switch $link1, $link2, $link3 - lnd, lna, fnd, fna, drd, dra)? Thanks!
  5. Thanks Larry. Has the Registration script been updated to MySQLi in a later edition of your book? If so, can you please tell me which version so I can get it? Thanks again!
  6. Hi Larry! Recently my hosting company started running PHP 5.6 and now I'm getting the following error for Script 13.7 User Registration An error occurred in script '/home/example/public_html/includes/mysql_connect.php' on line 14: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead Date/Time: 9-24-2016 11:27:29 Can you please share what the fix is for this? Thanks!
  7. Got it! Here's how I did it for anybody looking to do the same: // Fetch and print all the records. $bg = '#eeeeee'; // Set the background color. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { if ($row['publish']=="1") { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color. echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="' . $row['field4'] . '">' . $row['field1'] . '</a></td> <td align="left">' . $row['field2'] . '</td> <td align="left">' . $row['field3'] . '</td> <td align="left"><a href="' . $row['field5'] . '">' . "Link2" . '</a></td> </tr> '; } else { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color. echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="' . $row['field4'] . '">' . $row['field1'] . '</a></td> <td align="left">' . $row['field2'] . '</td> <td align="left">' . $row['field3'] . '</td> <td align="left"></td> </tr> '; } } echo '</table>';
  8. I only get the parse error messages when I try to cut into the while loop, otherwise it works great (thanks Larry!). Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/example/public_html/example.php on line 122 I noticed Larry addressed a similar post a few years ago here http://www.larryullm...39568#msg-39568 "What you need to do is have the while loop create TDs--one for each iteration--instead of TRs. The problem is that the loop also has to create new TRs as appropriate and close old TRS as appropriate. And complete the last TR if there's an odd number of records. I just use a flag variable for this purpose. This is untested but may work for you: $n = 0; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { if ($n == 0) { echo '<tr>'; } echo "<td><img src=\"show_image.php?image={$row['thumbnail']}\"></img></td> <td width=\"20px\"></td>\n"; $n++; if ($n == 2) { echo '</tr>'; $n = 0; } } if ($n == 1) { echo '<td></td> <td width=\"20px\"></td> </tr>'; } Also, there is no closing IMG tag. Best Wishes, Larry Writer/Web Developer/Instructor Forum Moderator
  9. Hi Jonathon, I'm using Larry's registration script 8.6 This is the section of the code that prints the table // Fetch and print all the records. $bg = '#eeeeee'; // Set the background color. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color. echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="' . $row['field4'] . '">' . $row['field1'] . '</a></td> <td align="left">' . $row['field2'] . '</td> <td align="left">' . $row['field3'] . '</td> <td align="left"><a href="' . $row['field5'] . '">' . "Link2" . '</a></td> </tr> '; } echo '</table>';
  10. Thanks Craig. Changed the code as you suggested but unfortunately, I'm still getting same parse error. Something else must be going on that I'm not seeing. -Bob
  11. hmmm... still getting parse errors Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/example/public_html/example.php on line 122 Thanks anyway Craig, -Bob
  12. Thanks Craig! I'll check it out. The problem I've had has been getting something to work within the while loop and table framework. Thanks again, -Bob
  13. I have a table that has URLs for some records in the fourth column and then records that don't have URLs. To distinguish the two, I use a field called 'publish' (set to 1 for records with, 2 for records without). // Fetch and print all the records. $bg = '#eeeeee'; // Set the background color. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color. echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="' . $row['field4'] . '">' . $row['field1'] . '</a></td> <td align="left">' . $row['field2'] . '</td> <td align="left">' . $row['field3'] . '</td> <td align="left"><a href="' . $row['field5'] . '">' . "Link2" . '</a></td> </tr> '; } echo '</table>'; // How do I get the records without URLs to not print this <td align="left"><a href="' . $row['field5'] . '">' . "Link2" . '</a></td> but instead, print this? <td align="left"></td> Thanks! -Bob
×