Jump to content

memfiss

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://psychopathy.fd0.ru

Profile Information

  • Gender
    Male
  • Location
    Lithuania

memfiss's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ur input is a filter ? U can use jquery+ajax pagination , then u will save all filters or just save it into session
  2. <? class Number { private $number; private $numbers; function __construct($nr) { $this -> number = strval($nr); $this -> numbers = array(); $this -> numbers[] = $nr[0]; $this -> numbers[] = $nr[1]; $this -> numbers[] = $nr[2]; $this -> numbers[] = $nr[3]; } function Get($index) { return isset($this -> numbers[$index]) ? $this -> numbers[$index] : null; } function Get2() { $array = array(); $array[] = $this -> Get(0) . $this -> Get(1); $array[] = $this -> Get(1) . $this -> Get(2); $array[] = $this -> Get(2) . $this -> Get(3); return $array; } function GetAllVariations() { $array = array(); for ($i1 = 0; $i1 < 4 ; $i1++) for ($i2 = 0; $i2 < 4 ; $i2++) for ($i3 = 0; $i3 < 4 ; $i3++) for ($i4 = 0; $i4 < 4 ; $i4++) { $array[] = $this -> Get($i1) . $this -> Get($i2) . $this -> Get($i3) . $this -> Get($i4); } return $array; } } $numbers = "8512,1812,2325,2326,2623,3236,3738,3932,5256,6169"; $win = 8521; $numbers = explode(',', $numbers); foreach($numbers as $num) { #check 100% if ($num == $win) { echo '*Match 4 numbers in the correct order win <b>100%</b> of the jackpot. (Odds: 1 in 10,000)<br>'; continue; } #check 2 numbers in correct : $nr = new Number($num); foreach ($nr->Get2() as $cur) { if (strpos($win,$cur) !== false) { echo "*Match 2 numbers in the correct order win <b>40%</b> of the jackpot. (Odds: 1 in 833)<br>"; } } #4 in wrong: if (in_array( $win, $nr -> GetAllVariations())) echo '*Match 4 numbers in the wrong order win <b>20%</b> of the jackpot. (Odds: 1 in 417)<br>'; }
  3. " $result2 = array(); while ($array = mysql_fetch_array($query, MYSQL_ASSOC)) { $result2[] = $array; } " u dont need second variable $result2 = array(); while ($result2[] = mysql_fetch_array($query, MYSQL_ASSOC)); "want to set 3-10 start.gif and 6-10 end.gif " u can made some config , like $img_conf ['3-10'] = 'start.gif' and then call it $img = isset($img_conf [$variable]) ? $img_conf [$variable] : null;
  4. working smtp email sending script (it's old , just for example) <? #configured for mail.ru $config['smtp_username'] = '********@mail.ru'; //ur email adress $config['smtp_port'] = '25'; //dont change it if u dunno $config['smtp_host'] = 'smtp.mail.ru'; //server adress $config['smtp_password'] = '*************'; $config['smtp_charset'] = 'UTF-8'; $config['smtp_from'] = 'TEST'; //"from:" function smtpmail($mail_to, $subject, $message, $headers='') { global $config; $SEND = "Date: ".date("D, d M Y H:i:s") . " UT\r\n"; $SEND .= 'Subject: =?'.$config['smtp_charset'].'?B?'.base64_encode($subject)."=?=\r\n"; if ($headers) $SEND .= $headers."\r\n\r\n"; else { $SEND .= "Reply-To: ".$config['smtp_username']."\r\n"; $SEND .= "MIME-Version: 1.0\r\n"; $SEND .= "Content-Type: text/plain; charset=\"".$config['smtp_charset']."\"\r\n"; $SEND .= "Content-Transfer-Encoding: 8bit\r\n"; $SEND .= "From: \"".$config['smtp_from']."\" <".$config['smtp_username'].">\r\n"; $SEND .= "To: $mail_to <$mail_to>\r\n"; $SEND .= "X-Priority: 3\r\n\r\n"; } $SEND .= $message."\r\n"; if( !$socket = fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 30) ) { return false; } if (!server_parse($socket, "220", __LINE__)) return false; fputs($socket, "HELO " . $config['smtp_host'] . "\r\n"); if (!server_parse($socket, "250", __LINE__)) { fclose($socket); return false; } fputs($socket, "AUTH LOGIN\r\n"); if (!server_parse($socket, "334", __LINE__)) { fclose($socket); return false; } fputs($socket, base64_encode($config['smtp_username']) . "\r\n"); if (!server_parse($socket, "334", __LINE__)) { fclose($socket); return false; } fputs($socket, base64_encode($config['smtp_password']) . "\r\n"); if (!server_parse($socket, "235", __LINE__)) { fclose($socket); return false; } fputs($socket, "MAIL FROM: <".$config['smtp_username'].">\r\n"); if (!server_parse($socket, "250", __LINE__)) { fclose($socket); return false; } fputs($socket, "RCPT TO: <" . $mail_to . ">\r\n"); if (!server_parse($socket, "250", __LINE__)) { fclose($socket); return false; } fputs($socket, "DATA\r\n"); if (!server_parse($socket, "354", __LINE__)) { fclose($socket); return false; } fputs($socket, $SEND."\r\n.\r\n"); if (!server_parse($socket, "250", __LINE__)) { fclose($socket); return false; } fputs($socket, "QUIT\r\n"); fclose($socket); return TRUE; } function server_parse($socket, $response, $line = __LINE__) { global $config; while (substr($server_response, 3, 1) != ' ') { if (!($server_response = fgets($socket, 256))) { return false; } } if (!(substr($server_response, 0, 3) == $response)) { return false; } return true; }
  5. this query without "ORDER BY" turn in 4s. , with "ORDER BY" about 30s. SELECT TRIM(LEFT(`ResignLogin`.`ResignReason`, 50)) AS `Reason`, `ResignLogin`.`ResignDate`, `ResignLogin`.`CountryID`, `Login`.`LangID` , `ResignStatus`.`Status` FROM `ResignLogin` LEFT JOIN `Login` ON `ResignLogin`.`LoginID` = `Login`.`LoginID` LEFT JOIN `ResignStatus` ON `ResignLogin`.`LoginID` = `ResignStatus`.`LoginID` ORDER BY `ResignLogin`.`ResignDate` DESC LIMIT 10; explain : +----+-------------+--------------+--------+---------------+---------+---------+-----------------------------+--------+---------------------+ | id | select_type | TABLE | TYPE | possible_keys | KEY | key_len | REF | ROWS | Extra | +----+-------------+--------------+--------+---------------+---------+---------+-----------------------------+--------+---------------------+ | 1 | SIMPLE | ResignStatus | system | PRIMARY | NULL | NULL | NULL | 0 | const ROW NOT found | | 1 | SIMPLE | ResignLogin | ALL | NULL | NULL | NULL | NULL | 401369 | USING filesort | | 1 | SIMPLE | Login | eq_ref | PRIMARY | PRIMARY | 30 | ABSOLUX.ResignLogin.LoginID | 1 | | +----+-------------+--------------+--------+---------------+---------+---------+-----------------------------+--------+---------------------+ how can i make it faster ? tnx.
  6. one more ) before AS result SELECT (400 + ((2 - 1) * 600)) + ((400 + ((4 - 1) * 600)) - (400 + ((2 - 1) * 600)) * (1 - (((1343715769 - 1343715694) - (1343715814 - 1343715694)) / (1343715769 - 1343715694))) - (CEIL((400 + ((2 - 1) * 600)) + ((400 + ((4 - 1) * 600)) - (400 + ((2 - 1) * 600))) / 600))) AS result; +----------+ | result | +----------+ | 598.0000 | +----------+ 1 row in set (0.00 sec)
  7. have u added enctype in ur form ? <FORM enctype="multipart/form-data" method="post">
  8. php make connection to sql server , then u can send queries to server and get answers from it http://www.php.net/manual/en/ref.mssql.php
  9. u need to make table with question answers and id then when u henerate html code of ur form select one random question and id place question id into hidden input and after submiting check is answer correct
  10. function create_input($name) { if (isset($_POST['$name'])) { #wrong index if (isset( $_POST[$name] )) { #and may be u needed to put value $_POST[$name] ? #and no needed variable function create_input($name) { if(isset( $_POST[$name] )) return "<input type='text' name='" . $name . "' id='" . $name . "' value='" . $_POST[$name] . "' />"; return "<input type='text' name='" . $name . "' id='" . $name . "' value='' />"; } ... $article_id = $_GET['article_id']; # maybe il put text into get variable ? $article_id = (int)$_GET['article_id']; ... while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $Qs[] = $row['question']; $As[] = $row['answer']; $_SESSION['Q'] = $Qs; $_SESSION['A'] = $As; } #no needed variable $_SESSION['Q'] = array(); $_SESSION['A'] = array(); while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $_SESSION['Q'] [] = $row['question']; $_SESSION['A'] [] = $row['answer']; }
  11. <table width="403" border="0" cellpadding="5"> <?php echo '<input name="count" type="hidden" value="'.mysql_num_rows($rs_fooditem).'">' $i=0; do { ?> <tr> <td width="146"><?php echo $row_rs_foods['name']; ?></td> <td width="147"><?php echo $row_rs_foods['price']; ?></td> <td width="82"> <form action="" method="post"> <input name="idfood" type="hidden" value="<?php echo $row_rs_foods['idfoods']; ?>" /> <input name="adddish<?php echo $i;?>" type="submit" value="Add Meal" /> </form> </td> </tr> <?php $i++; } while ($row_rs_fooditem = mysql_fetch_assoc($rs_fooditem)); ?> </table> <?php $count = (!empty($_POST['count'])) ? intval($_POST['count']) : 0; $i = 0; while ($i < $count && $count != 0) { if(isset($_POST['adddish'.$i])) { $food = mysql_real_escape_string($_POST['idfood'.$i]); $menu = $_GET['menu']; $course = $_GET['course']; $insertq = mysql_query("INSERT INTO foodlink (idmenu, idfood, course) VALUES ('$menu', '$food', '$course')") or die(mysql_error()); $i++; } } header("Location: add-existing-foods.php"); ?>
  12. u should read about sessions on php http://php.net/manual/en/features.sessions.php
  13. in this part no problems $_SESSION['tablea']['numbers1-6'] = 1; if (isset($_SESSION['tablea']['numbers1-6'])) { $_SESSION['tablea']['numbers1-6prior'] = $_SESSION['tablea']['numbers1-6']; unset($_SESSION['tablea']['numbers1-6']); } var_dump($_SESSION['tablea']['numbers1-6']); Notice: Undefined index: numbers1-6 in /var/www/absolux/test/run.php on line 8 NULL
  14. cuz u use wrong INSERT syntax , should be INSERT INTO `table` ( `here` , `are` , `columns` ) VALUES ( 'here' , 'are' , 'values' );
×
×
  • 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.