Philip
Staff Alumni-
Posts
4,665 -
Joined
-
Last visited
-
Days Won
20
Everything posted by Philip
-
Unknown column 'uname' in 'field list' That's in your insert query - and it means that cokumn doesn't exist in your database structure. Are you sure you have a 'uname' and not 'uName' or 'username' or something like that?
-
http://php.meetup.com/42/ That's mine Overall calendar : http://php.net/cal.php
-
[SOLVED] Counting How Many Lines Are Inside Certain Markup Tags.
Philip replied to Vermillion's topic in PHP Coding Help
echo $result[0][$current]; Should be: echo $current; -
dynamic community sites- message board vs bulletin board forum
Philip replied to yamahammer's topic in Miscellaneous
Yeah, I'm the same way. The help/general discussion on HTML-Kit is laid out horribly in my opinion. I hate newsgroups/message boards like that! I guess I'm just a forum guy -
Both - although I feel I'm too much of a perfectionist, and instead of getting decent code out there, I keep making minor adjustments... thus it's never really complete (typically my own sites). However, when deadlines loom around, I can get it done within the time frame. xlyex - I just started meeting with some local programmers myself, and I must agree it helps a lot. I have to ask though, have you/do you attend any PHP meetings around? There is a group where I'm at, but I'm a bit hesitant about going for some reason
-
[SOLVED] Counting How Many Lines Are Inside Certain Markup Tags.
Philip replied to Vermillion's topic in PHP Coding Help
Oops! Had a typo, fixed version below: <?php error_reporting(E_ALL); // create a test string: $string = "Blah blah hello world =) [code]Code for you? skip a few ahah testing hehe one line "; // a new function, with 1 parameter that is required // note, i did change this so the string was required unlike the original function countLines($String) { // setup a new array, dont put anything in it yet $lines = array(); // if it successful in finding code tags in the string if( preg_match_all('#\ [code\]([^]]+)\[/code\]#i', $String, $Matches, PREG_SET_ORDER)){ // get line count $lineCount = count($Matches); // setup an array $returnArray = array(); // loop through each match for($i=0; $i<$lineCount; $i++) { // create a temporary array, for each line of the code tag // (when there are multiple lines inside ) $test = explode("\r\n", $Matches[$i][0]); // if the first line is just , we should get rid of it if($test[0] == '[code]') { array_shift($test); // (shifts array, so it'll ignore the [code] } // if the last line is , we need to "pop" it off the array if($test[count($test)-1] == '[/code]') { array_pop($test); // pretty much deletes the array item ([/code] } // count how many array items (or lines) are in the array still $returnArray[$i]['num'] = count($test); // and give the data back: $returnArray[$i]['data'] = preg_replace(array('~\ [code\]~','~\[/code\]~'), '',$test); } } // return the array of the line counts for each block return $returnArray; } // show an example of what it looks like and what values to call echo '<pre>'; print_r(countLines($string)); echo '</pre>'; ?>[/code] (missing an 'e' in '$Matches', line 34) -
[SOLVED] Counting How Many Lines Are Inside Certain Markup Tags.
Philip replied to Vermillion's topic in PHP Coding Help
Here we go: <?php error_reporting(E_ALL); // create a test string: $string = "Blah blah hello world =) [code]Code for you? skip a few ahah testing hehe one line "; // a new function, with 1 parameter that is required // note, i did change this so the string was required unlike the original function countLines($String) { // setup a new array, dont put anything in it yet $lines = array(); // if it successful in finding code tags in the string if( preg_match_all('#\ [code\]([^]]+)\[/code\]#i', $String, $Matches, PREG_SET_ORDER)){ // get line count $lineCount = count($Matches); // setup an array $returnArray = array(); // loop through each match for($i=0; $i<$lineCount; $i++) { // create a temporary array, for each line of the code tag // (when there are multiple lines inside ) $test = explode("\r\n", $Matchs[$i][0]); // if the first line is just , we should get rid of it if($test[0] == '[code]') { array_shift($test); // (shifts array, so it'll ignore the [code] } // if the last line is , we need to "pop" it off the array if($test[count($test)-1] == '[/code]') { array_pop($test); // pretty much deletes the array item ([/code] } // count how many array items (or lines) are in the array still $returnArray[$i]['num'] = count($test); // and give the data back: $returnArray[$i]['data'] = preg_replace(array('~\ [code\]~','~\[/code\]~'), '',$test); } } // return the array of the line counts for each block return $returnArray; } // show an example of what it looks like and what values to call echo '<pre>'; print_r(countLines($string)); echo '</pre>'; ?>[/code] That'll show: Array ( [0] => Array ( [num] => 5 [data] => Array ( [0] => Code for you? [1] => [2] => skip a few [3] => ahah [4] => testing ) ) [1] => Array ( [num] => 1 [data] => Array ( [0] => hehe one line ) ) -
[SOLVED] Counting How Many Lines Are Inside Certain Markup Tags.
Philip replied to Vermillion's topic in PHP Coding Help
Just call $Matchs[0], $Matchs[1] etc.... it'll still show the though. -
I typically don't use it - I prefer using full syntax with braces. However, this application is a bit smaller than what I'm used to working on, so I don't think it will matter too much
-
Oops, my bad, change foreach($row as $k => $v) { to foreach($array as $k => $v) {
-
while ($row = mysql_fetch_array($query)) { $username = $row['username']; $email = $row['email']; $count++ ; } if($numrows > 1){ $return = "results";} else{ $return = "result"; } print "<p>Your search for $search returned $numrows $return.</p>"; print "$email<br>$username"; That loop will only set the last row found. You need to either create an array, each array item being an array of the results, or print directly from the loop. $array = array(); while($row = mysql_fetch_array($query) $array[] = $row; $return = (($numrows>1) ? "results":"result"); // if there should be an s or not print "<p>Your search for $search returned $numrows $return.</p>"; // show string foreach($row as $k => $v) { // run loop through each array element echo 'Email: ',$v['email']; echo 'Name: ',$v['username'],"\n"; }
-
is incorrect syntax (I believe) Changing $query = mysql_query($sql); to $query = mysql_query($sql) or die(mysql_error()); would have helped
-
I haven't used it, but I'll honestly say I think it's a waste of money. If done properly, typically a majority of your code can be re-used from other projects. Also, there are tons of open-source stuff that does the same thing (and more!) and they are 100% FREE! Which would save you what, $400-600!?
-
Oops, sorry I should be in bed sleeping instead of surfin' the web
-
/* build selection list for the year */ $today = time(); $startYr = date("Y", $today); //get the year from $today echo "<select name='syear'>\n"; $endYr = $startYr-90; // get the date you want to end up at for ($syear=$startYr;$syear<=$endYr;$syear--) { echo " <option value=$syear"; if ($startYr == $syear ) { echo " selected"; } echo "> $syear\n"; } echo "</select>\n";
-
[SOLVED] Counting How Many Lines Are Inside Certain Markup Tags.
Philip replied to Vermillion's topic in PHP Coding Help
<?php // create a test string: $string = "Blah blah hello world =) [code]Code for you? skip a few ahah testing hehe one line "; // a new function, with 1 parameter that is required // note, i did change this so the string was required unlike the original function countLines($String) { // setup a new array, dont put anything in it yet $lines = array(); // if it successful in finding code tags in the string if( preg_match_all('#\ [code\]([^]]+)\[/code\]#i', $String, $Matchs, PREG_SET_ORDER)){ // loop through each match foreach($Matchs AS $Match) { // create a temporary array, for each line of the code tag // (when there are multiple lines inside ) $test = explode("\r\n", $Match[0]); // if the first line is just , we should get rid of it if($test[0] == '[code]') { array_shift($test); // (shifts array, so it'll ignore the [code] } // if the last line is , we need to "pop" it off the array if($test[count($test)-1] == '[/code]') { array_pop($test); // pretty much deletes the array item ([/code] } // count how many array items (or lines) are in the array still $lines[] = count($test); } } // return the array of the line counts for each block return $lines; } // show an example of what it looks like and what values to call var_dump(countLines($string)); ?>[/code] Does that help? --oops, looks like it didnt like it in code tags, we'll have to use -
Also, are magic quotes on and you are using addslashes( ) That would put like: Then stripslashes only takes one set away:
-
As thorpe said, you need to sanitize your input.... But the query problem lies here: `city2` = '{$_POST['city2']}, (You're missing a ' ) `city2` = '{$_POST['city2']}',
-
Im glad you think so
-
Would if a number is between 1 and 4 automatically knock the other 2 qualifications out? If the number is 0, its not between 1 and 4, and if the number is 3, 3 isn't greater than 750, lol By the way, if you check if that number is between 1 and 4, including 1 and 4: if($var >= 1 && $var <=4)
-
You deleted it from the wrong location. Note: _dl, not _cats
-
while($row_rs_multi_dl = mysql_fetch_assoc($rs_multi_dl)); } That } afterwards is not needed. Proper indenting would help
-
Look at this line with a syntax highlighter: echo "<div class='catdetail_header'><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>" ; echo '<div class="catdetail_header"><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>' ; See the difference?
-
http://locusmeus.com/html-css/centerexample3.html
-
[SOLVED] Php5 array not working, worked in php4
Philip replied to noexcal's topic in PHP Coding Help
As CV suggested - just use an array and cut out the middleman while($app_info = $database->database_fetch_assoc($app)) { $app_array[] = $app_info; } You'd have to change your query a little bit (select exactly what you want) $app_query = "SELECT `user_id`,`app_info1`,`item_id`,`profile`,`name`,height`,`width`+10 as width FROM se_apps WHERE user_id='".$this->user_info[user_id]."' AND app_info2=1 AND profile=1 ORDER BY order_id ASC LIMIT 0,30";