sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
sorry '/\[yt\]http:\/\/youtube.com\/watch\?v=(.*?)\[\/yt\]/' escape '?' too
-
just after 1st e-mail send 2nd
-
use 'LEFT JOIN' in your SQL
-
in your query you don't select news_body just news_id and news_title $query = "SELECT news_id, news_title, news_body FROM news ORDER BY news_id DESC LIMIT 0,3";
-
are you try this[codeg<?php $a = 'Servers Lab,Servers Non_Standard,Servers Group,Servers Operations,Servers DEV,Servers TS,DEV,Servers RIB,Non_Standard,Servers Infrastructure,Servers CITRIX,Infrastructure,Servers CITRIX,DEV,Servers CITRIX,Operations,Servers CITRIX,Lab,Servers TS,Infrastructure,Servers TS,Operations,Servers TS,Lab,Servers Stage,Infrastructure,Servers'; $a = explode("\n",$a); foreach ($a as $v) { $b[] = implode('/',array_reverse(explode(',',$v))); } echo '<pre>'; print_r($b); echo '</pre>'; // or foreach ($a as $v) { if (strpos($v, ',')) $c[] = implode('/',array_reverse(explode(',',$v))); } echo '<pre>'; print_r($c); echo '</pre>'; ?>
-
error is in line <li><a href="">latest posts</a></li>
-
youtube.com\/watch
-
Insert data to a table, I can't see why it doesn't work
sasa replied to MrMagooba's topic in PHP Coding Help
change $sql = "INSERT INTO topicstarter ('posttitle', 'postdate', 'poster', 'message') VALUES ('$posttitle','$postdate','$poster','$message')"; to $sql = "INSERT INTO topicstarter (posttitle, postdate, poster, message) VALUES ('$posttitle','$postdate','$poster','$message')"; or $sql = "INSERT INTO topicstarter (`posttitle`, `postdate`, `poster`, `message`) VALUES ('$posttitle','$postdate','$poster','$message')"; -
Calling mysql_fetch_array twice on the same $result...Legal?
sasa replied to kvishnu_13's topic in PHP Coding Help
Use mysql_data_seek($result,0) -
or <?php $a ='*sasa*dfg*jkl*55555*6666'; preg_match_all('/\*([^\*]+)/',$a, $b); print_r($b[1]); ?>
-
try <?php $var = " Servers; Lab,Servers; Non_Standard,Servers; Group,Servers; Operations,Servers; DEV,Servers; TS,DEV,Servers; RIB,Non_Standard,Servers; Infrastructure,Servers; CITRIX,Infrastructure,Servers; CITRIX,DEV,Servers; CITRIX,Operations,Servers; CITRIX,Lab,Servers; TS,Infrastructure,Servers; TS,Operations,Servers; TS,Lab,Servers; Stage,Infrastructure,Servers "; $var = str_replace("\n",'',$var); $var = explode(';',$var); foreach ($var as $str) { $str = explode(',',$str); $tmp1 = array(); $tmp2 = array(); if (count($str) > 1){ $tmp2[$str[1]] = $str[0]; for ($i = 2; $i < count($str); $i++) { $tmp1[$str[$i]] = $tmp2; $tmp2 = $tmp1; } } else $out[] = $str[0]; $out = array_merge_recursive($out,$tmp2); } print_r($out); ?>
-
[SOLVED] Darn code's not doin' what I want it to do...
sasa replied to christofurr's topic in PHP Coding Help
no it match that have character that is not one of this 'a-zA-Z0-9 ' ' ' is space you are right don't need both a-z and A-Z -
[SOLVED] Darn code's not doin' what I want it to do...
sasa replied to christofurr's topic in PHP Coding Help
try <?php $nicktrim = 's a s a 123+456'; if (eregi('[^a-zA-Z0-9 ]',$nicktrim)) echo 'NO'; else echo 'OK'; ?> -
try <?php function my_rand($a, $b, $c=3) { $a = floor($a) * (++$c) + ($a - floor($a)) * 10; $b = floor($b) * $c + ($b - floor($b)) * 10; $x = rand($a, $b); $out = floor($x / $c) * 10 + ($x % $c); return $out / 10; } $start = 14.1; $end = 16.2; echo my_rand($start, $end); ?>
-
try <?php mysql_connect('localhost') or die('blek'); mysql_select_db('test'); $sql ="Select distinct size from invertory_size where TID=2 order by size asc"; $r = mysql_query($sql) or die('upš'); while ($row = mysql_fetch_array($r)){ $pos[$row['size']] = $i++; } $sql ="Select * from invertory_size where TID=2 order by tag_no asc, size asc"; $r = mysql_query($sql) or die('upš'); echo '<table border="3"> <tr> <td width="100">Tag No.</td>'; foreach ($pos as $key => $value) echo "<td bgcolor=\"034FFF\" width=\"50\" align=\"center\">",$key,'</td>'; echo'<td align="right" width="100">Pieces</td> <td align="right" width="100">Lineal</td> <td align="right" width="100">FBM</td></tr>'; $curent = ''; $start = true; while ($row = mysql_fetch_array($r)){ if($start) { echo '<tr><td>', $row['tag_no'],'</td>'; $i = 0; $start = false; } elseif ($row['tag_no']!=$curent) { $curent = $row['tag_no']; while ($i++ < count($pos)) { echo '<td> </td>'; //$i++; } echo '<td> </td><td> </td><td> </td></tr><tr><td>'.$row['tag_no'].'</td>'; $i = 0; } while ($i++ < $pos[$row['size']]) { echo '<td> </td>'; //$i++; } echo '<td>',$row['qty'],'</td>'; } while ($i++ < count($pos)) echo '<td> </td>'; echo '<td> </td><td> </td><td> </td></tr></table>'; ?>
-
Index.php <?php //connect mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("directory") or die(mysql_error()); //select table $result = mysql_query ("SELECT * FROM countries"); //get entries //$row = mysql_fetch_array ($result); <--- remove this line //print result while ($row = mysql_fetch_array ($result)){ $id=$row["Id"]; $status=$row["Status"]; $country=$row["Country"]; echo "<a href=\"showlinks.php?id={$id}\">{$country}[/url] "; } ?> Showlinks.php <?php //connect mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("directory") or die(mysql_error()); $id = $_GET['id']; // <---- add this line if(!isset($id)) { die("Invalid ID"); } $id = $_GET["id"]; $query = mysql_query("SELECT * FROM links WHERE Id = '{$id}'") or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { // Output... $id1=$row["id"]; echo "$id1"; } ?>
-
try <?php require_once ('../mysql_connect.php'); // first update database if($_POST['Submit']){ foreach ($_POST['id'] as $key => $id){ $rate_a = $_POST['rate_a'][$key]; $rate_b = $_POST['rate_b'][$key]; $sql1="UPDATE tbl_shipping SET sh_us_overnight='$rate_a', sh_us_economy='$rate_b' WHERE id='$id'"; $result1 = mysql_query($sql1) or die(mysql_error()); } } $sql="SELECT * FROM tbl_shipping"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Id</strong></td> <td align="center"><strong>Overnight</strong></td> <td align="center"><strong>Economy</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"><input type="hidden" name="id[]" value="<?php echo $rows['sh_us_id']; ?>"><?php echo $rows['sh_us_id']; ?></td> <td align="center"><input name="rate_a[]" type="text" id="name" value="<? echo $rows['sh_us_overnight']; ?>"></td> <td align="center"><input name="rate_b[]" type="text" id="lastname" value="<? echo $rows['sh_us_economy']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> </table> <?php // Check if button name "Submit" is active, do this if($result1){ header("location:index.php"); } mysql_close(); ?>
-
[SOLVED] Really strange behavior from foreach in PHP5
sasa replied to natbur's topic in PHP Coding Help
Try to change 1st foreach loop (ones with reference &$test) <?php $TextBoxData['TextBox1'] = Array ( 'name' => "TextBox1", 'value' => "Question1", 'show' => 1, 'required' => 1, 'text' => "Answer1" ); $TextBoxData['TextBox2'] = Array ( 'name' => "TextBox2", 'value' => "Question2", 'show' => 1, 'required' => 1, 'text' => "Answer2" ); $TextBoxData['TextBox3'] = Array ( 'name' => "TextBox3", 'value' => "Question3", 'show' => 1, 'required' => 1, 'text' => "Answer3" ); $TextBoxData['TextBox4'] = Array ( 'name' => "TextBox4", 'value' => "Question4", 'show' => 1, 'required' => 1, 'text' => "Answer4" ); echo "Vardump<br />"; var_dump($TextBoxData); echo "<hr>Before first loop<br />"; print_r($TextBoxData); //TextBoxes foreach($TextBoxData as $key => $text) { if($text['required'] == 1 && $text['text'] == "") { $TextBoxData[$key]['missing'] = 1; $missing++; } } echo "<hr>Before second loop<br />"; print_r($TextBoxData); $first = 1; foreach($TextBoxData as $text) { if($text['text'] != "") { if($first == 1) { $msg .= "<br />Has the following additional information to share<br /><br />"; $first = 0; } $msg .= "- In Response to: <br />"; $msg .= " {$text['value']} <br />"; $msg .= " - They said : <br />"; $msg .= " {$text['text']} <br />"; } } echo $msg; echo "<hr>After all loops<br />"; print_r($TextBoxData); echo "<hr>Vardump<br />"; var_dump($TextBoxData); ?> -
[SOLVED] Really strange behavior from foreach in PHP5
sasa replied to natbur's topic in PHP Coding Help
what filter_text function do? -
try <?php //Board Information $space = ' '; $ident_array = array('main' => 0, 'sub' => 1, 'subsub' => 2); $boards = array( array("main", "General Board", "forum.php?id=1", "This should go under the General Boad"), array("sub", "Sub Genderal", "forum.php?id=2", "This should go under the Sub general Board"), array("subsub", "Sub Sub Genderal", "forum.php?id=12", "This should go under the Sub sub general Board"), array("main", "Misc Board", "forum.php?id=3", "This should go under the Misc Board"), array("sub", "Sub Misc", "forum.php?id=4", "This Should go under the Sub Misc Board") ); foreach ($boards as $x) { echo str_repeat($space, $ident_array[$x[0]]),'<a href="',$x[2],'">',$x[1],'</a><br />',"\n"; echo str_repeat($space, $ident_array[$x[0]]),$x[3].'<br />'; } ?>
-
are you star and end <table> tags I try <?php $cache = '<table border="3">'; //$dbtable = 'table_care'; //$depts = $db->Execute("SELECT * FROM $dbtable WHERE batch_nr='92'"); //while($row= $depts->FetchRow()){ //$h = $row['serial_value']; $h = '&=carand=1-2=3=1&=laptan=4-14=3=2'; $keywords = preg_split ("/[\=,\&]+/", "$h"); for ($i = 1; $i < count($keywords); $i += 4) { $cache .= '<tr>'; for ($j = 0; $j < 4; $j++) { if ($i + $j < count($keywords)) { $cache.='<td> '.$keywords[$i + $j].' </td>'."\n"; } else $cache .= '<td> </td>'."\n"; } $cache .= '</tr>'; } //} echo $cache, '</table>'; ?> and output is OK
-
[SOLVED] Grabbing text from files/strings/etc
sasa replied to iLLeLogicaL's topic in PHP Coding Help
if you wont to grab all type of input, not just hidden, change line preg_match_all ('/<input[^>]+hidden[^>]+>/',$text,$b); to preg_match_all ('/<input[^>]+>/',$text,$b);