Jump to content

serious1234

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

serious1234's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i have a script that randomly chooses questions and answers from mysql datase. i used rand but the problem is when I refresh the page everything changes new questions and new answers. is there a way I can make these questions and the answers not change when refreshing the page.
  2. i have a database that has questions and i want to make random of 20 questions of these but in condition that it must be unique and i don't want the same result to show up again or more than once.what is the best way to do that.
  3. I tried a way to solve the problem. I added something to change . to _ so as to avoid the problem but it doesn't replace the . but replaces anything else.i think this is very odd!! anyone can help ?
  4. I have a script that put a file in zip archive and make it available for download. my problem is that when i download those zipped files they come with number.. for example my file is something like avenging.srt and when it becomes avenging.[1].srt.zip . everything is ok but my problem is with the dot before the file extension srt. Everytime i download the same file it changes to the same name with different number like avenging[2].srt.zip , avenging[3].srt.zip and when i use a name without extension like avenging it is ok the zip file comes as I want it to be. and this is part of the code: --------------------------- require ("incl/pclzip.lib.php"); $newname=$name.".zip"; $zipfile = new PclZip($newname); $v_list = $zipfile->create($name); if ($v_list == 0) { die ("Error: " . $zipfile->errorInfo(true)); } header("Content-type: application/octet-stream"); header("Content-disposition: attachment; filename=$newname"); readfile($newname); //this is to delete the modified file and the zipped one after being downloaded unlink($name); unlink($newname); print "done"; ?> ------------ can you help make those zip files come with names without numbering and i saw this idea in a subtitle site and it works fine.
  5. i want to make a page that display database contents as follows. at the top of the page i want to show details of the selected message the name of the author , date and subject and the message itself with a PREVIOUS PAGE | NEXT PAGE under them and after that there is a list of all the messages. my question is how could i do it that when someone click on a link on the list or click previous or next page button to get the right information. i just did that but my problem is with the order because in the database it happened that i dropped some rows and there was a difference inorder that makes wrong information when clicking on a specific link. this is the code and i hope you could help me. pardon me guys because i am new to php programming and you might find odd things in my codes. here is the code code: <?php include 'connect.php'; $page1=24; if(isset($_GET['message'])){$page1=$_GET['message']; } // how many rows to show per page $rowsPerPage =1; // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; }else {$pageNum=$page1-23;} // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; $query = "SELECT * FROM comments LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query failed'); // print the random numbers $row = mysql_fetch_array($result); echo $row['date_auto'] . '<br>'; echo $row['name'] . '<br>'; echo $row['subject'] . '<br>'; echo $row['comment'] . '<br>'; $aqeel=$row['autoID']; echo '<br>'; if(!isset($_GET['page'])){$aqeel=$message;} // how many rows we have in database $query = "SELECT COUNT(comment) AS numrows FROM comments"; $result = mysql_query($query) or die('Error, query failed'); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); // print the link to access each page $self = $_SERVER['PHP_SELF']; // creating previous and next link // plus the link to go straight to // the first and last page if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page\">Prev Message</a> "; } else { $prev = ' '; // we're on page one, don't print previous link } if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page\">Next Message</a> "; } else { $next = ' '; // we're on the last page, don't print next link $last = ' '; // nor the last page link } // print the navigation link echo $prev ."|". $next ; echo "<br>"; $query1 = "SELECT * FROM comments LIMIT 25 "; $result1 = mysql_query($query1) or die('Error, query failed'); while($row1 = mysql_fetch_array($result1)) { if ($row1[autoID]==$aqeel ){ print "<b>$row1[subject]</b><br>";}else{print "<a href='Copy of Copy of paging.php?message=$row1[autoID]'>$row1[subject]</a><br>";} } ?> my database tables are -- phpMyAdmin SQL Dump -- version 2.9.1.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Apr 28, 2007 at 02:57 AM -- Server version: 5.0.27 -- PHP Version: 5.2.0 -- -- Database: `serious` -- -- -------------------------------------------------------- -- -- Table structure for table `comments` -- CREATE TABLE `comments` ( `autoID` int(10) NOT NULL auto_increment, `name` varchar(64) NOT NULL, `email` varchar(64) NOT NULL, `subject` varchar(100) NOT NULL, `status` enum('seen','hidden') NOT NULL, `comment` text NOT NULL, `date_auto` int(10) NOT NULL, `approved` enum('0','1','2') NOT NULL default '2', PRIMARY KEY (`autoID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=68 ;
  6. i followed a video tutorial to make a guestbook using php but when i fininshed typing the file and executed it. it showed me an error that says "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\myguestbook.php on line 38" and line 38 has the following "  for ($i = 0; $i < mysql_num_rows($result); $i++)" and here is the script : [code] <?php require ($_SERVER["DOCUMENT_ROOT"]."/config/db_connect.php"); $connection = @mysql_connect ($db_host, $db_user, $db_password) or die ("error connecting"); mysql_select_db($db_name, $connection); $name = $_POST["txt_name"]; $len= strlen($name); //Only write to database if there's a name if ($len >0) { $email = $_POST["txt_email"]; $comment =$_POST["txt_comment"]; $date = time (); $query = "INSERT INTO guestbook (autoID, name, email, comment, date_auto) VALUES (NULL, '$name','$email','$comment','$date')"; mysql_query($query, $connection) or die (mysql_error ());   }   ?> <html> <head> <title>Guestbook</title> <body> <center> <form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="post"> <font face="arial" size="1">      Name: <input type="text" name="txt_name">&nbsp;      Email:<input type="text" name="txt_email"><br><br>      Comment:<br>      <textarea style="width: 75%" rows="10" name="txt_comment"></textarea>      <center><input type="submit" value="submit"</font></center> </form> <table bgcolor="#AAAAAA" border="0" width="75%" cellspacing="1" cellpading="2" <?php $query="SELECT * FROM questbook ORDER BY date_auto"; $result = mysql_query($query, $connection);   for ($i = 0; $i < mysql_num_rows($result); $i++) {      $name = mysql_result($result, $i, "name");      $email = mysql_result($result, $i, "email");      $email= strlen($email);      $comment = mysql_result($result,$i, "comment");      $date = mysql_result($result,$i, "date_auto");      $show_date ("H:i:s m/d/Y" , $date);      echo '      <tr>      <td width="50%" bgcolor="#EEEEEE">      <font face="arial" size="2">';      if ($email_len > 0)      {      echo '<b>Name:</b> <a href="mailto:'.$email.'>"'.$name.'</a>';      }      else      {      echo '<b>Name:</b> '.$name;      }      echo '      <br>      <b>Comment:</b> '.$comment.'      </font>      <td>      <td width="1%" valign="top" nowrap bgcolor="#EEEEEE">      <b>Date: </b> '.$show_date.'      </font>      </td>      </tr>       ';      }      ?> </table> </center> </body> </html> [/code]
×
×
  • 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.