Jump to content


  • Posts

  • Joined

  • Last visited


About CrashOkami

  • Birthday 10/15/1992

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Athina, Hellas

CrashOkami's Achievements


Newbie (1/5)



  1. I got "undefined variable" and "index", and I wrote the code like this: <?php $pagenum = isset($_GET['pagenum']) ? intval($_GET['pagenum']) : 1; ?> Seems to be working now, can you please clarify that this is what you also did? Just to see if I got it right. Thanks a ton for your help
  2. It prints 30 records ($rows = mysql_num_rows($data); $page_rows = 30; ), but now I've set it to print as many as the database has ($page_rows = $rows;) until I fix this issue. I really can't seem to find it.
  3. That's great to know, thank you very much! True, I "had" no errors, I'll go edit the php.ini as you said. Thanks! EDIT: now it refreshes the page, renews the URL, but I'm still getting the results available for page 1 only. Maybe I should not limit the results to 30 the way I do?
  4. Hello once more, I'm having trouble with my pagination code. It's all going fine, queries and all, until the time that I have to change page. It just won't change, whether I hit Last or Next. <?php mysql_connect("##", "##","##") or die("Failed to connect."); mysql_select_db("##") or die("Failed to find database."); if (!(isset($pagenum))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM news") or die("Could not execute query."); $rows = mysql_num_rows($data); $page_rows = 30; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $data_p = mysql_query("SELECT * FROM news $max") or die("Could not fetch query data."); while($info = mysql_fetch_array( $data_p )) { Print "<a href='news.php?News_ID=" .$info['News_ID']."'>"; Print $info['Title']; Print "</a>"; Print ", written at "; Print $info['Date']; echo "<br>"; } echo "<p>"; echo " --Page $pagenum of $last-- <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } echo " ---- "; if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?> As it is, it fetches 30 results, and I have around 55 in my database. What's wrong when it comes to changing pages though? Can you help me sort this out? Thank you in advance!
  5. There's none for me, maybe because I'm a new user? I can't even mark your answer as an answer to the topic, which would be the same. Still, thanks for pointing that out!
  6. Silly, silly me. I've fixed it, and I'm pasting the code below case anyone stumbles upon this for help. { Print "<a href='news.php?News_ID=" .$info['News_ID']."'>"; Print $info['Title']; Print $info['Date']; Print "</a>"; echo "<br>"; } Moderators, please mark this as solved. Thank you!
  7. Hello, The code below is part of a pagination code, which is working perfectly until I put the <a href> code in it, so the results can be made links to the article in accordance. Problem is, I'm getting "undefined T_VARIABLE" on the first line of this. I know I've done a mistake with the quotes, for sure, but I can't seem to be able to fix it. { Print "<a href='news.php?News_ID="$info['News_ID'] " '>"; Print $info['Title']; Print $info['Date']; Print "</a>"; echo "<br>"; } I've used spaces where needed to make the quotes more easily visible. Thank you again!
  8. Yup, I meant that I need no programs etc, just alter the code, commands, functions and all that. Thanks for the clarification, though
  9. I can't thank you enough for all this, I will start the conversion process later. So, basically, wherever I spot a "MySQL", I change it to "MySQLi", and it's converted to MySQLi. Thank you again! I suggest the mods leave this open so if anyone finds the error in the above code posts the solution to it.
  10. Meh, still same, points me to the ELSE statement. Should I try rebuilding my whole database with MySQLi? Would it be worth it? At the very least, now would be the best time to do it, since it's empty of records, save for 1 admin account, and the tests which I'm always deleting.
  11. This is greatly appreciated, HDFilmMaker. Indeed, when my contract with this host ends (if not earlier), I will move on to a host with MySQLi. As noted under my profile picture, I'm a beginner, so I was unaware of this problem, and didn't bother searching for the differences between MySQL and MySQLi, so I didn't care if the host supported it or not. I'll try your code now and edit this post to let you know if it worked, thank you! EDIT: now it points me to the ELSE error: "Error, please fill in all the fields as needed. If the problem persists, contact the webmaster.", although I've filled in all the fields as needed :/
  12. I've uploaded my newest version of the site, but I found out I can't post any kind of text that has an apostrophe in it, which is impossible, since I'm writing full articles. I've read topics about "my_sql_real_string()", but I can't figure out how to implement it to my existing code. Plus, I have no means of transforming my MySQL database into a MySQLi at the moment. Since I get the error I've set to come when the query cannot be executed, I suppose this function has to be inside the query, right? So, can you please show me how to do it in the code below? <?php $Title = $_POST["Title"]; $Small_desc = $_POST["Small_desc"]; $Desc = $_POST["Desc"]; $Image = $_POST["Image"]; $Author = $_POST["Author"]; if(!$Title=="" && !$Small_desc=="" && !$Desc=="" && !$Image=="" && !$Author=="") { $db_name = "###"; $link = mysql_connect("###", "###","###") or die("There was an error connecting to the database."); $select_db = mysql_select_db($db_name, $link); $add_query="INSERT INTO news(News_ID, Title, Small_desc, Description, Image, Author, Date) values (NULL, '$Title', '$Small_desc', '$Desc', '$Image', '$Author', NOW())"; $add_results = mysql_query($add_query, $link) or die("Record not inserted. Could not execute query. Please try again. <br> <br>"); echo "Record successfully inserted. Go back to the <a href=admin_index.php>admin index page.</a>"; } else { echo "Error, please fill in all the fields as needed. If the problem persists, contact the webmaster."; } ?> Where ### = my database/host details. Thank you once again! Although on most of my topics, I figure it out before someone posts the solution, I believe this will not be the case here.
  13. That's a flood of information, I've bookmarked the topic for easy finding when in need of such tips. You guys are awesome, I asked for something trivial and I got a ton of tips
  14. Wow, although I got it to work, thank you for your detailed replies I will surely implement your code, since it looks (obviously) more professional than mine, and it looks it can give more/better results on errors, queries etc. Thank you PS: The parameter is indeed News_ID, my teacher always told me that it should always be lower-case, but I want everything to look tidy - I'm sure I'll change along the way, though, and use lower-case, as does the rest of the world
  • 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.