Jump to content

87dave87

Members
  • Posts

    86
  • Joined

  • Last visited

Everything posted by 87dave87

  1. ok this is working now, was a problem with the code from dbconnect file ending php statement
  2. If I put the query code directly into the head.php file, it works. [code] <?  $url = $_SERVER['REQUEST_URI']; $query = mysql_query("SELECT platform FROM windows_atari2600 limit 0,1"); $row = mysql_fetch_assoc($query); if($url == '/') { echo "<title>emulators.cc - console and handheld for blah de blah</title>"; } if(strpos($url, "about")!== false)  { echo "<title>emulators.cc > About Us</title>"; } if(strpos($url, "windows")!== false)  { echo "<title>emulators.cc > Windows Emulators > "; echo $row['platform']; echo "</title>"; } if(strpos($url, "mac")!== false) { echo "<title>emulators.cc > Mac Emulators > "; echo $row['platform']; echo "</title>"; } if(strpos($url, "linux")!== false) { echo "<title>emulators.cc > Linux Emulators > "; echo $row['platform']; echo "</title>"; } else { echo "<title>emulators.cc</title>"; } ?> [/code] So everything must be fine, but then when I move the query to the subpage, it doesnt.. does php allow variables to be passed to included files?
  3. It is the same everytime because in my search box for this site there can be various emulators with the same platform but with different operating systems. Using the $platform idea they are generated straight from when I update the database.
  4. Hi, I have created this code to automatically create browser titles: - [code] <?  $url = $_SERVER['REQUEST_URI']; if($url == '/') { echo "<title>emulators.cc - console and handheld for blah de blah</title>"; } if(strpos($url, "about")!== false)  { echo "<title>emulators.cc > About Us</title>"; } if(strpos($url, "windows")!== false)  { echo "<title>emulators.cc > Windows Emulators > "; echo $row['platform']; echo "</title>"; } if(strpos($url, "mac")!== false) { echo "<title>emulators.cc > Mac Emulators > "; echo $row['platform']; echo "</title>"; } if(strpos($url, "linux")!== false) { echo "<title>emulators.cc > Linux Emulators > "; echo $row['platform']; echo "</title>"; } else { echo "<title>emulators.cc</title>"; } ?> [/code] The way this works is if 'windows' is in the url, e.g. www.emulators.cc/windows/ then it displays 'emulators.cc > Windows Emulators > ' in the title, the problem comes with echo $row['platform']; which should display a the result of a field from my database which contains the platform an emulator is based, e.g. Atari 2600.  So then the title would be 'emulators.cc > Windows Emulators > Atari 2600' The above code is placed in my head.php include, before this include is called to on my sub page (e.g. emulators.cc/windows/atari2600/) I have this code (which is the query): - [code] <? include($_SERVER['DOCUMENT_ROOT'] . '/includes/dbconnect.php');  $query = mysql_query("SELECT platform FROM windows_atari2600 limit 0,1"); $row = mysql_fetch_assoc($query); include($_SERVER['DOCUMENT_ROOT'] . '/includes/head.php'); ?> [/code] This should work fine as the query is there, and then when head.php is included, it should show the platform (it does work if the query is put into the head.php include).  So why doesnt it work outside the head.php include? Thanks again!
  5. grrr! im lost with this!! why can't IE handle things the way Safari/Firefox does! Doesn't work at all for me in IE7
  6. Can someone check if a favicon is displaying at http://www.emulators.cc/ in IE? It doesnt seem to be working in mine, i just need to check that its cached the old IE favicon. Works in Safari.
  7. Okay, I think I have this sussed now! Thanks for your help, hopefully have a finished version to show off soon.
  8. The include works, ive got another error before redirect now when I try typing something thats not found 'gdsogsgoisog' or something that is in the database 'Atari' Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/irrm3a/public_html/search.php on line 14 I cannot see anything wrong with this: - [code] if (empty($_POST['emusearch'])) {   echo "<meta http-equiv='refresh' content='0; URL=/searchnoresults.php'>";   exit(); } else { $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows < 1) {     echo "<meta http-equiv='refresh' content='0; URL=/searchnoresults.php'>"; exit(); } else  include ('http://www.emulators.cc/includes/head.php'); [/code]
  9. Okay, The way I have this set up is: - First thing in code, include for dbconnect.php (with connect info) Then if this is the search page I have my $sql code for selecting tables from database and comparing the string data, which is in seperate php tags. Then further down I have sql code again where it is displaying the rows. It appears to be connecting on my front page and sub page. code: - [code] <?php require_once('http://www.emulators.cc/includes/dbconnect.php'); ?> <?php $sql = "select emulator, version, os, platform, details from windows_atari2600 where emulator LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' OR platform LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' order by platform asc, emulator asc"; if (empty($_POST['emusearch'])) {   echo "<meta http-equiv='refresh' content='0; URL=/searchnoresults.php'>";   exit(); } else { $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows < 1) {     echo "<meta http-equiv='refresh' content='0; URL=/searchnoresults.php'>"; exit(); } else  include ('http://www.emulators.cc/includes/head.php'); ?> <table width="600" border="0">   <tr>     <td>     <table width=600 border=0 cellpadding=0 cellspacing=0>     <tr>         <td>             <img src="/images/searchresults.jpg" width=300 height=30 alt="Search Results"></td>         <td>             <table border="0" cellpadding="0" cellspacing="0" width="290" height="30" background="/images/barmid.jpg">               <tr>                 <td>                 <div align="right"> <?php echo "<p class='footer'>"; echo $num_rows; if ($num_rows == "1") { echo " emulator found</p>"; } else{ echo " emulators found</p>";} ?>                 </div></td>               </tr>             </table>         </td>         <td>             <img src="/images/barend.jpg" width=10 height=30 alt="Search Results"></td>     </tr> </table>     </td>   </tr>   <tr>     <td><table width="100%" border="0" cellpadding="0" cellspacing="0">         <tr class="tablehead">           <td width="240">Emulator</td>           <td width="120">Version</td>           <td width="120">OS</td>           <td width="120">Platform</td>           <td width="120">Details</td>         </tr> <?php if (isset($_POST['emusearch']) && strlen(trim($_POST['emusearch'])) > 0){   $sql = "select emulator, version, os, platform, details from windows_atari2600 where emulator LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' OR platform LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' order by platform asc, emulator asc";   if(!$rs = mysql_query($sql)){       echo "Error<br>".mysql_error()."<br>".$sql;       exit();   }   else{       $num_rows = mysql_num_rows($rs);       while ($get_info = mysql_fetch_row($rs)) {         echo "<tr>";         foreach ($get_info as $field){             echo "<td>$field</td>\n";         }             echo "</tr>\n";       }   } } ?>       </table> </table> <?php include ('http://www.emulators.cc/includes/search.php'); include ('http://www.emulators.cc/includes/foot.php'); }  ?> [/code] maybe this is occuring because $sql is in there twice?
  10. The code you just used does the same as what I was using before, it flashes this for a split second: Warning: mysql_real_escape_string(): Access denied for user nobody@localhost using password: no
  11. Thanks that worked. Is it possible to include a file at the top of a page that contains your MySQL connection information? I tried this and while the file works and connects to mysql if I type it directly into my browser, it doesnt work when the file is included from my other pages?
  12. Hi, I have written a fairly simple search script for a website I am working on, the search box works great, it shows the results and if it cannot find the text that is entered it redirects to a page telling the user that it cannot find information. Now im stuck with the code to write incase the user doesn't enter anything into the search box. This is my code for the current redirect: - [CODE] <? $database="database";  mysql_connect ("localhost", "user", "pass"); @mysql_select_db($database) or die( "Unable to select database"); $sql = "select emulator, version, os, platform, details from windows_atari2600 where emulator LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' OR platform LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' order by platform asc, emulator asc"; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows < 1) {     echo "<meta http-equiv='refresh' content='0; URL=/searchnoresults.php'>"; } else if(   { include ('http://www.emulators.cc/includes/head.php'); ?> [/CODE] Im planning on putting the redirect code for when nothing is entered into the last 'If(' part. Any help would be appreciated. Thanks in advance.  :)
  13. k, just done a bit of editting to that and its working fine! thanks a lot... not sure how this has actually worked... but its great!  Ill study it later on.
  14. the yellow 'search results bar' with the php error... thats where im putting the 'found emulators' code.
  15. it works, but as the bar is outside of my result code, I can't do anything with it still.
  16. no... if you do a search now its getting an error for the num_rows??
  17. total found. So if some types in 'stella', at the moment that gives 1, so it will display '1 emulator found'
  18. Hi,  I have a search results page and I want to display $num_rows (so I can put Found 'x' downloads), but my code which has If statements from when it is started is below where I want the $num_rows to appear. e.g. http://www.emulators.cc/  -  type 'atari' into the search box at the top and click go... this will display the results but I can't get the 'emulators found' part to work. This is because im not declaring the sql query first, although ive tried to do this... The code for the 'found 'x' emulators is:- [code] <?php $database="database";  mysql_connect ("localhost", "user", "pass");  @mysql_select_db($database) or die( "Unable to select database"); $num_rows = mysql_num_rows($sql); echo "<p class='footer'>";  echo $num_rows; echo " emulators found</p>";  ?> [/code] Code for the results to be displayed is: - [code]         <?php if(isset($_POST["emusearch"]) && strlen(trim($_POST["emusearch"])) > 0){     $database="database";      mysql_connect ("localhost", "user", "pass");      @mysql_select_db($database) or die( "Unable to select database");      $sql = "select emulator, version, os, platform, details from windows_atari2600 where emulator LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' OR platform LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' order by platform asc, emulator asc";      if(!$rs = mysql_query($sql)){          echo "Error<br>".mysql_error()."<br>".$sql;              exit();    }     if(!mysql_num_rows($rs)){          echo "<tr>";  echo "<meta http-equiv='refresh' content='0; URL=http://www.google.com/foundnorecordspage'>";         echo "</tr>\n";      }else{          while ($get_info = mysql_fetch_row($rs)) {                echo "<tr>";                foreach ($get_info as $field) echo "<td>$field</td>\n";              echo "</tr>\n";          }      }  }else{     echo "<meta http-equiv='refresh' content='0; URL=http://www.google.com/searchcriteriarequired'>"; } ?> [/code]
  19. Ok, but when I display 'updated' after the date format its already changed, and as I dont use newupdated.. it can be removed.
  20. Ok, ive done that and it works: - <?php  $database="irrm3a_emulators";  mysql_connect ("localhost", "irrm3a", "reallydo3t");  @mysql_select_db($database) or die( "Unable to select database"); $sql = mysql_query("SELECT emulator, version, DATE_FORMAT(updated, '%d %b %Y') AS newupdated, rating, readme, screenshot, download FROM windows_atari2600 order by rating desc, updated desc"); while ($get_info = mysql_fetch_row($sql)) {    echo "<tr>";    foreach ($get_info as $field) echo "<td>$field</td>\n";   echo "</tr>\n"; } ?> Do I really need the AS newupdated part? Its not actually doing anything is it?
  21. Hi, This is my page which displays data in one of my database tables: - http://www.emulators.cc/windows/atari2600/test.php As you can see, the rows are listed by the rating (im not sure how its done this - is this because there is more text in the rating field as there is more html code for each star?). If the rating is the same as another row I then want the rows displayed in order of rating and which is the most up to date record. At the moment it is not recognizing the year in the date field. The php code for the above page is: - <?php  $database="database";  mysql_connect ("localhost", "user", "pass");  @mysql_select_db($database) or die( "Unable to select database"); $sql = mysql_query("SELECT emulator, version, DATE_FORMAT(updated, '%d %b %Y') AS updated, rating, readme, screenshot, download FROM windows_atari2600 order by rating desc, updated desc"); while ($get_info = mysql_fetch_row($sql)) {    echo "<tr>";    foreach ($get_info as $field) echo "<td>$field</td>\n";   echo "</tr>\n"; } ?>
  22. I am trying to create a search box which queries my database tables and if the text entered into the input box is the same as the field 'emulator' then it will return the results of the entire row. The following code works except when text is entered which doesnt match the 'emulator' field: - [code] <?php   $database="mydatabase";   mysql_connect ("localhost", "user", "pass");   @mysql_select_db($database) or die( "Unable to select database"); $sql = mysql_query("select * from windows_atari2600 where emulator = '$_POST[emusearch]'"); if(isset($sql)){ while ($get_info = mysql_fetch_row($sql)) {     echo "<tr>";     foreach ($get_info as $field) echo "<td>$field</td>\n";   echo "</tr>\n"; } }else{   echo "<tr>";   echo "We cannot find your infomation.";   echo "</tr>\n"; } ?> [/code] I have also tried the following code but now the results arent shown and any text entered into the input box returns 'We cannot find your information' [code] <?php   $database="mydatabase";   mysql_connect ("localhost", "user", "pass");   @mysql_select_db($database) or die( "Unable to select database"); $sql = mysql_query("select * from windows_atari2600 where emulator = '$_POST[emusearch]'"); if($sql==""){ while ($get_info = mysql_fetch_row($sql)) {     echo "<tr>";     foreach ($get_info as $field) echo "<td>$field</td>\n";   echo "</tr>\n"; } }else{   echo "<tr>";   echo "We cannot find your infomation.";   echo "</tr>\n"; } ?> [/code] Any help would be greatly appreciated.
  23. No doesn't seem to, just displays 'We cannot find your infomation' no matter what is entered :?
×
×
  • 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.