Jump to content

Rogue3

Members
  • Content Count

    27
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Rogue3

  • Rank
    Member

Profile Information

  • Gender
    Not Telling
  1. After some trial and error, I may have finally got all of the code fixed properly. I would love it if someone could just have a look and make sure everything looks OK. The script is running as expected, and I'm not getting any errors in my error log. <?php $host = "XYZ"; $user = "XYZ"; $pass = "XYZ"; $dbname = "XYZ"; $connection = mysqli_connect($host,$user,$pass) or die (mysqli_errno().": ".mysqli_error()."<BR>"); $database = mysqli_select_db($connection, $dbname); $prefix = "nuke"; $query = mysqli_query($connection, "SELECT * FROM ".$prefix."_jreviews"); $num_rows = mysqli_num_rows($query); $rannum = rand(1,$num_rows); $sql = "SELECT id, title, imagethumb FROM ".$prefix."_jreviews WHERE id='$rannum'"; $result = mysqli_query($connection, $sql); list($id, $title, $imagethumb) = mysqli_fetch_array($result); if (!empty($imagethumb)) { echo "<a href=\"/content/modules.php?name=JReviews&rop=showcontent&id=$id\"><img src=\"$imagethumb\" align=\"center\" border=\"0\" width=\"100\" height=\"100\" alt=\"$title\" title=\"$title\"></a>"; } else { echo "<a href=\"/content/modules.php?name=JReviews&rop=showcontent&id=$id\"><img src=\"/images/rdr-blank.jpg\" align=\"center\" border=\"0\" width=\"100\" height=\"100\" alt=\"$title\" title=\"$title\"></a>"; } ?> I also removed the line closing the connection, as recommended.
  2. I simply asked how to convert the code from mysql_ to mysqli_ It wasn't a long script so I didn't think I need to post what failed, as I had undone the changes as the script failed to run. I tried most of the obvious solutions to convert this but it still failed, so I'm sure there is some extra syntax that I'm forgetting with the new mysqli.
  3. Wow, thanks for that. What exactly is the point of having a PHP Coding Help forum if all everyone is going to do is tell you to read the manual? I worked on this and researched this for hours before I came here and pretty much exhausted the level of my expertise. That's whay I came here, for help. But thanks for that advice. I never knew to check there.
  4. The output error being received is: Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /path/path/path/Random_Review.php I did try to convert it to mysqli but was not very successful. Unfortunately, I'm not very adept at writing PHP code, so I'm sure there's some basic notation that I'm missing.
  5. I'm updating code to get rid of the PHP errors in the error log after moving to PHP 5.6. I'd rather correct the code than suppress the errors. I've tinkered with fixing this one but I keep crashing the code so I'm obviously leaving something out. It's a pretty short script, so hoping someone more versed in this language can show me how to make the mysqli_ corrections. Thanks in advance! <?php $host = "localhost"; $user = "XYZ"; $pass = "XYZ"; $dbname = "XYZ"; $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); $prefix = "nuke"; $query = mysql_query("SELECT * FROM ".$prefix."_jreviews"); $num_rows = mysql_num_rows($query); $rannum = rand(1,$num_rows); $sql = "SELECT id, title, imagethumb FROM ".$prefix."_jreviews WHERE id='$rannum'"; $result = mysql_query($sql); list($id, $title, $imagethumb) = mysql_fetch_array($result); if (!empty($imagethumb)) { echo "<a href=\"/content/modules.php?name=JReviews&rop=showcontent&id=$id\"><img src=\"$imagethumb\" align=\"center\" border=\"0\" width=\"100\" height=\"100\" alt=\"$title\" title=\"$title\"></a>"; } else { echo "<a href=\"/content/modules.php?name=JReviews&rop=showcontent&id=$id\"><img src=\"/images/rdr-blank.jpg\" align=\"center\" border=\"0\" width=\"100\" height=\"100\" alt=\"$title\" title=\"$title\"></a>"; } mysql_close($connection); ?>
  6. I tried updating the query string as suggested, but that did not work. Perhaps the problem lies deeper in the code. Just to note, this did function properly before moving from 5.3 to 5.6. I don't know if that helps point to possible changes in the language. Here's the full code for that page: https://pastebin.com/X8Fw3qEp Here's a link to the page generating the 'random' years: http://www.jeditemplearchives.com/archives/ --> Note: Any link pre-June 2017. After that, it uses Wordpress for the archives.
  7. Part of my site still runs on an older CMS (PHP Nuke) so that our archived articles can still be accessed. To access them, we have an archive page that archives the articles by month. I recently upgraded our server to PHP 5.6 (from 5.3) and it broke some of the older Nuke code. Nothing major, just little things here and there. One of them was how the monthly archives are loading. When you click on a link to the month it will bring up the correct month but the year is completely random. It will pull up years before the internet even around! I suspect there is something in the result code causing this, but I'm not sure what to change or try to get it to properly identify the year. Here is the current result call: $result = $db->sql_query('SELECT aid, informant, sid, catid, title, hometext, time, comments, counter, topic, alanguage, score, ratings from '.$prefix.'_stories WHERE time >= \''.$year.'-'.$month.'-01 00:00:00\' AND time <= \''.$year.'-'.$month.'-31 23:59:59\' order by sid DESC'); I anyone has any suggestions I'm all ears! I can provide more code if it looks like this isn't the culprit, or even the entire function. The generated link looks like this: modules.php?name=Archives&sa=show_month&year=2013&month=01&month_l=January The year in the generated link is always correct. It's the content on the page that is incorrect.
×
×
  • 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.