Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try <?php $test = ' <img src="http://www.yoursite.com/yourpic.jpg"> bla bla <img src="pic2.bmp" alt="bla"> bla 2 2 bla '; $x = '/(<img.*src="([^"]+)"[^>]*>)/i'; $to = '<script> britepic_src="$2"; britepic_id="your_unique_britepic_id"; </script> <script src=\'http://www.britepic.com/britepic.js\'> </script> <noscript> $1 </noscript>'; echo preg_replace($x,$to,$test); ?>
  2. or try // Connect to the host. $link = OpenConnection(); $todaysDate = date("Y-m-d"); $query = "INSERT INTO $dbaseUserData (lid,username,password,email,icon,usertype,since) values ('$leagueID','$username','$encryptpass','$email','$icon','1','$todaysDate');"; $query .= "INSERT INTO user_details (username,password,email) values ('$username','$encryptpass','$email');"; $result = mysql_query($query) or die("Query failed: $query"); CloseConnection($link);
  3. coss, but did you understund logic if i type short way good luck with php
  4. try SELECT c.first_name cap_first, c.last_name cap_last, v.first_name v_cap_firs, v.last_name v_cap_last FROM Teams LEFT JOIN users c ON captain=c.user_id LEFT JOIN users v ON vice_captain =v.user_id WHERE Teams.club_id = '$id'
  5. try <?php $arr = array("first" => "apples", "second" => "oranges", "third" => "bananas"); $var = "first"; //THIS IS A MADE-UP FUNCTION NAME, OBVIOUSLY... if(array_get_key_index($arr, $var) !== false) echo array_get_key_index($arr, $var); else echo 'err'; function array_get_key_index($arr, $var){// first index is 0 if (!is_array($arr)) return false; $a = array_keys($arr); return array_search($var, $a); } ?>
  6. CREATE TEMPORARY TABLE new_tbl SELECT * FROM orig_tbl
  7. when you go direct to this page $_POST isn't set yet and page don't show part from if (isset($_POST['Submit'])) { to last one }
  8. <?php $a = file('insert_filename_here'); // connect db foreach ($a as $b) { preg_match('/([0-9]+)\s*http[^0-9]*([0-9]+)/',$b,$c); $price = $c[1]; $id = $c[2]; // update table } ?>
  9. you use same name for both query results ($result) change one of them $result1 = mysql_query("SELECT Company, City, State, Phone FROM dog_account WHERE `username` = '$Username' ", $db) or die(mysql_error()); while($myrow = mysql_fetch_array ($result1)) { $Company=$myrow['Company']; $City=$myrow['City']; $State=$myrow['State']; $Phone=$myrow['Phone']; }
  10. look http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html#option_mysqld_Threads_connected
  11. try <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="../main.css" /> </head> <body> <?php mysql_connect("localhost", "admin", "admin") or die("Cannot connect to DB!"); mysql_select_db("padgate") or die("Cannot select DB!"); $hall = "SELECT * FROM userhall WHERE hallid = '6'"; $h = mysql_query($hall) or die(mysql_error()."<Br /><br /.".$hall); // don't use your SQL statement in your error. It will let malicious users know your table structure and open it up to sql injection. //$rowa = mysql_fetch_array($h); //move this line3s down //$userid = $rowa['id']; ?> <div id="center"> <div id="logo"> <img src="../images/padcommlogo.png" alt="PadComm" /></div> <?php include("../php/login.php"); ?> <div id="date"> <script language="JavaScript" type="text/javascript"> <!-- var currentTime = new Date() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() document.write("Today's date is: ") document.write(day + "/" + month + "/" + year) //--> </script> </div> <?php include("../php/navigation.php"); ?> <div id="content"> <h1>Croft Hall</h1></p> <?php if(mysql_num_rows($h) < 1) { echo 'Apparently no one lives in Croft hall!' ; } else { echo 'The following people live in Croft Hall! </p>'; while($rowa = mysql_fetch_array($h)) { //$rowa = mysql_fetch_array($h); //move in while condition //$userid = $rowa['id']; $hallmembers = "SELECT * FROM user WHERE id = '$userid'"; $m = mysql_query($hallmembers) or die(mysql_error()."<Br /><br /.".$hallmembers); // don't use your SQL statement in your error. It will let malicious users know your table structure and open it up to sql injection. $row = mysql_fetch_array($m); //echo 'The following people live in Croft Hall! </p>'; this line move before while loop echo $row['f_name']; echo ' '; echo $row['l_name'],"<br />\n"; } } ?> </div> <?php include("../php/footer.php"); ?> </div> </body> </html>
  12. are you ever see more then one record?
  13. when you pass variabl with URL in array $_GET is value of passed variable
  14. you did NOT have error just notice
  15. try $conn = mysql_connect($hostname, $user, $dbpassword); if(!$conn) { } else { $db1 = mysql_select_db($database, $conn); //$insertqueryresult = mysql_query($insertqueryfortable1); //$lastid = mysql_insert_id(); $selectqueryoftable1 = "Select username, password, email from table1 where 1 ORDER BY slno DESC LIMIT 1"; $selectunempsq = mysql_query($selectqueryoftable1,$db1); $rowunemps = mysql_fetch_assoc($selectunempsq); $unis = $rowunemps['username']; $psis = $rowunemps['password']; $emis = $rowunemps['email']; $db2 = mysql_select_db($database2, $conn); $insertqueryfortable2 = "Insert into table2(username, password, email) VALUES ('$unis', '$psis', '$emis')"; $unpsemresult = mysql_query($insertqueryfortable2,$db2);
  16. change $pagename = $_GET['page']; to if(isset($_GET['page']))$pagename = $_GET['page']; else $pagename = "";
  17. try $sql = "SELECT * FROM Armor LEFT JOIN DesignHasArmor ON DesignHasArmor.DesignID = $DesignID AND Armor.ArmorID = ArmorsEquipped.ArmorID";
  18. put if(isset($_GET['offset'])) $offset = $_GET['offset']; near the top of script
  19. change your form to <input name="orders[501][order]" type="text" id="order-501" value="" maxlength="50" /> <input name="orders[501][customerID]" type="hidden" id="customerID-501" value="2%" maxlength="50" /> </td> <td><input name="orders[501][sale]" type="text" id="sale-501" value="0.00" maxlength="15" /></td> </tr>
  20. try ... $admin = 'NOT<br>'; while ($row = mysql_fetch_array($user_id)) if(in_array(19, $row)) $admin = "ADMIN<br>"; echo $admin; } else { echo "You have entered an invalid username/password combination"; }
  21. if you want to replace first 9 spaces with comma try <?php $a = '1 A AB 2 ABC 3 ABCD 4 5 The whitespace inbetween these must not be replaced with a comma'; //$a = 'SIP25071 O 4.4 43 4 ERG 02/28/2008 Mike cisco2000 ptime.baseval header incorrect chk in'; for ($c = 0;$c < 9; $c++) $a[strcspn($a,' ')] = ','; echo $a; ?>
  22. try <?php //gets a list of unique manufacturer names from db $manu_query = "SELECT DISTINCT manu_id FROM new_product WHERE modal_no <> '' ORDER BY manu_id"; $manu_result = mysql_query($manu_query); $manuName=''; $model_query = "SELECT id,manu_id,modal_no FROM new_product WHERE modal_no <> '' ORDER BY manu_id"; $model_result = mysql_query($model_query); $num=mysql_numrows($manu_result); //determining how many total rows there are in the resulting array echo "There are ". $num ." total rows in the manu_result. <br />"; $num2=mysql_numrows($model_result); //determining how many total rows there are in the resulting array echo "There are ". $num2 ." total rows in the model_result. <br />"; //displaying manufacturer name $manuName=''; while($row2 = mysql_fetch_assoc($model_result)) { if($manuName != $row2['manu_id']) { if($manuName) echo '</p>'; $manuName=$row2['manu_id']; echo "<p><strong>". $manuName ."</strong><br />"; } //while($row2 = mysql_fetch_assoc($model_result)) //{ //ensuring that the model number is only displayed for the corresponding manufacturer //if($row2['manu_id']==$row1['manu_id']) //{ //displaying model number as link to product page echo "<a href=\"./detail.php?prod_id=". $row2['id'] ."\">". $row2['modal_no'] ."</a> "; //} //} //end of inner while loop //echo "</p>"; } //end of outer while loop echo '</p>'; ?>
  23. try <?php $a = file_get_contents('http://www.uk-disco.co.uk/org-details.asp?OrgID=503'); preg_match_all('/mailto:([^\?]+)\?/',$a,$b); foreach ($b[1] as $email){ echo $email=html_entity_decode($email); } ?>
  24. try <?php $u = 'Z';//users choice $c = 'Y';//compute choice if ($u == $c) $res ='PUSH!'; else { $a = array('X', 'Y', 'Z'); $k = array_search($u,$a); $a[]='X'; if ($c == $a[$k+1]) $res = 'LOSES TO'; else $res ='BEATS'; } echo $res; ?>
×
×
  • 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.