sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
try with print_r() function
-
if you want to mach just start of last name try $countPlayers=mysql_query("SELECT players.Player_number, players.Player_name FROM players WHERE ((NOT Inactive_player) AND (players.Player_Last_Name LIKE '$player_find%')) ORDER BY Player_name"); or if you want to mach hole last name $countPlayers=mysql_query("SELECT players.Player_number, players.Player_name FROM players WHERE ((NOT Inactive_player) AND ((players.Player_Last_Name = '$player_find'))) ORDER BY Player_name"); $row = mysql_fetch_assoc($countPlayers) or die("No rows returned by query"); echo $row['Player_number']; $row = mysql_fetch_assoc($countPlayers) or die("No rows returned by query"); echo $row['Player_number'];[/code]
-
you must escape question mark $num_matches = preg_match_all("/imgres\?imgurl=(.+?).jpg/", $html, $matches);
-
change your query to $query = "SELECT * FROM productfeed WHERE description = '$description' LIMIT 0, 10"; string value in SQL must be qvouted
-
try echo "<form method=\"post\" action=".$PHP_SELF."> <label>aantal <input name=\"textfield[s]\" type=\"text\" size=\"4\" maxlength=\"3\"> <input name=\"textfield[M]\" type=\"text\" size=\"4\" maxlength=\"3\"> <input name=\"textfield[L]\" type=\"text\" size=\"4\" maxlength=\"3\"> <input name=\"textfield[XL]\" type=\"text\" size=\"4\" maxlength=\"3\"> <input name=\"textfield[XXL]\" type=\"text\" size=\"4\" maxlength=\"3\"> <</label> <input type=submit value=Select></form>"; and on submit page print_r($_POST['textfield']);
-
try <?php $multi_array = array( array("cats", "dogs", "sheep", "walruses"), array("jazz", "larva", "pencils", "derp"), array("to", "much") ); $string = array("the", "cats", "ate", "too", "many", "pencils"); $count = count($string); foreach($string as $i => $word) { foreach ($multi_array as $ar){ if(in_array($word, $ar)){ $string[$i] = $ar[array_rand($ar)]; break; } } } print_r($string); ?>
-
beter pass index and part of array
-
Correct syntax for echoing variables with values!
sasa replied to wright67uk's topic in PHP Coding Help
try $code = $_GET['postcode']; $shortcode = substr($code,0,2); $query =mysql_query ("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3"); echo mysql_error(); echo "<p>The email addresses you have requested are;</p>"; while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; echo "$nt[0],$nt[1],$nt[2]<br>"; echo "<p>please use $nt[2] if you ever want to contact me</p>"; //this line doesnt work for me ?></body></html> -
try <?php function gCodes($array) { $code = $array[1]; $var = $array[2]; switch($code) { case "IMG": $img = getImage($var); $return = "<a href=\"$img[location]\"><img src=\"$img[location]\" alt=\"$img[title]\"/></a>"; break; default: $return = "$code=>$var<br>Not Working<br>"; break; } return $return; } $text = "[img:1]"; $content = preg_replace_CALLBACK("/\[([A-Z]{3})[a-zA-Z0-9]+)\]/",'gCodes',$text); echo $content; ?>
-
add delimiter to your regex pattern <?php $link = 'http://bs.something.com/gghs-hc/09889/1442/importantparthere i want it to look like'; $link = preg_replace( "#http://bs.something.com/([^/\.]+)/([^/\.]+)/([^/\.]+)/#", "http://www.something.com/v/", $link); echo $link; ?>
-
try <?php Function OZCode($output){ static $i = 0; $i++; $output=$output[0]; echo $output, ' - ', $i, "<br />\n"; return $output; } $test = 'I need to get the data between [ozcode] and [/ozcode]I need to get the data between [ozcode] and bla[/ozcode]'; preg_replace_callback('~(?<=\[ozcode\]).*?(?=\[\/ozcode\])~', 'OZCode', $test); ?>
-
update code to if($_POST['Submit']){ $marketPrice = $_POST['marketPrice']; $auction = $_POST['auction']; $count = count($auction); for($i=0;$i<$count;$i++){ $sql1="UPDATE ships SET marketPrice='$marketPrice[$i]' AND auction='$auction[$i]' WHERE typeID='$typeID[$i]'"; $result1=mysql_query($sql1) or die(mysql_error()); }
-
try <?php $url_reg = "~(\w+)/plan/treats~"; $path = "dells/plan/treats"; echo $found = preg_match($url_reg, $path,$match); ?>
-
change [\w] to \w in pattern remove [ and ]
-
after use this code the value of variables $id is newer 'up'
-
try <?php $test = 'sasa,,word7,bond007'; if(preg_match('/((^|[^a-z0-9]),)|(,([^a-z0-9]|$))/i', $test)) echo 'No'; else echo 'OK'; ?>
-
you must generate new pasword before insert it in database
-
are you use moditer s for multi-line contest <?php $test = ' <div class="agent_display"> <dl> <dt>INSZONE INS. SERVICES INC.</dt> <dd>7200 Fair Oaks Blvd.</dd> <dd>Suite 210</dd> <dd>Carmichael, CA 95608</dd> <dd>Phone: (888) 988-9948</dd> <dd>Fax: (916) 486-4335</dd> <dd>Hours: </dd> <dd>M - F 8:00 a.m. to 7:00 p.m.</dd> <dd>License: OF82764</dd> <dd><a href="http://agents.mercuryinsurance.com/agentlocator/DisplayQuote.do?AgentCode=045238"><img src="images/faa_agents_button_contact.gif" alt="Contact this agent" /></a> </dd> </dl><br class="clear" /> </div><!-- close agent_display --> '; preg_match('/<div class=("|\')agent_display("|\')>(.*?)<\/div>/s', $test, $out); print_r($out); ?>
-
try <?php $test = 'function x1($p1,$p2) { echo \'test\'; echo \'test\'; } function x2($a) { if(1> 0){ echo \'hi\'; } }'; $test = ' '.$test; $fun = array(); $of = 0; while($sta = stripos($test, 'function', $of)){ $ob = stripos($test, '(', $sta+=7); $name = substr($test, $sta+1, $ob-$sta-1); $cb = stripos($test, ')',$ob); $param = substr($test, $ob+1, $cb-$ob-1); $cnt = 1; $start = strpos($test, '{', $cb); $ss = $start; while ($cnt){ $s = strpos($test, '{', $ss+1); $e = strpos($test, '}', $ss+1); if($s < $e and $s > 0){$cnt++; $ss = $s;} else {$cnt--; $ss = $e;} } $end = $ss; $body = substr($test, $start+1, $end - $start-1); $of = $ob; $fun[]= array(trim($name), trim($param), trim($body)); } print_r($fun); ?>
-
are you try it <?php $message = 'Step:111.Description:this is testing of &.Link:http://localhost/view.php?s=2&a=4.Endbla b la Step:2211.Description:this is testing of iiii&.Link:http://localhost/view.php?s=2&a=994.End xxxx Step:113.Description:this is testing of &2.Link:http://localhost/view.php?s=992&a=4.End'; $message = preg_replace('/Step:(\d+)\.Description:(.+?)\.Link:(.+?)\.End/', '\1 - <a href="\3">\2</a>', $message); echo $message; ?> as you see it works for multiple replaces Explain regex / - start of regex Step: - literaly (\d+) - one or more digits () means grab subparten, used in replace part as \1 \.Description: - literaly (.+?) - one or more caracther (? means shorten posible string) subparten \2 \.Link: literaly (.+?) - one or more characters \.End literaly /
-
try /<div class=("|\')agent_display("|\')>(.*?)<\/div>/
-
use htmlentities function http://php.net/manual/en/function.htmlentities.php
-
try <?php $test = 'saš-@đć++'; echo preg_replace('/[^\w]/', '', $test); ?>
-
Help - Find String within String between Pipes ||
sasa replied to SangrelX's topic in PHP Coding Help
try <?php $test = '|47||67||82||55||69|'; $find_id = 47; if (preg_match('/\|'.$find_id.'\|/', $test)){ echo "ID is there"; }else{ echo "NOT THERE -- Adding it"; } ?> -
try <?php $message = 'Step:111.Description:this is testing of &.Link:http://localhost/view.php?s=2&a=4.End'; $message = preg_replace('/Step:(\d+)\.Description:(.+?)\.Link:(.+?)\.End/', '\1 - <a href="\3">\2</a>', $message); echo $message; ?>