wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Pardon? Not fully understanding you. Are you saying your newlines are not being displayed? If so you'll need to convert newlines to <br /> in order for then to display on your page. PHP has a built in function which handles this for you called nl2br()
-
This is due to the comparison operator you are using here for($i = 0; $i < count($array1); $i++) { the < means less than. Say your array contained 3 items. The for loop will only iterate 2 times not 3. In order for it to iterate 3 times you'll need to use the less than or equal to operator (<=). EDIT: Ignore me.
-
Your now need to configure phpMyAdmin to use your new mysql username/password I recommend you to find phpMyAdmins configuration file (config.inc.php) and find the following line $cfg['Servers'][$i]['auth_type'] = 'config'; Change config to http instead. Now when you access phpMyAdmin a login prompt will be displayed.
-
[SOLVED] Help with .htaccess request directing
wildteen88 replied to Jagarm's topic in Apache HTTP Server
Then you'll specify a second rewrite rule. RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d # matches berwari.net/movies/40 RewriteRule ^(.*)/([0-9]+) index.php?display=$1&n=$2 [L] # matches berwari.net/movies RewriteRule ^(.*) index.php?display=$1 [L] -
Your could use array_map instead $query = "SELECT `name` FROM `table1` WHERE `name` IN('". implode("','", array_map('trim', $array1)) . "') ORDER BY CHAR_LENGTH(name) DESC"; Alternatively it could be done when you generate your $array1 array
-
You're still getting your braces mixed up. if( isset($_COOKIE['step1']) && !isset($_COOKIE['step2']) )
-
Your're missing a closing brace on this line:
-
[SOLVED] how to fetch 4 lines from 20 lines of description
wildteen88 replied to vinpkl's topic in PHP Coding Help
nl2br() will convert newlines to <br /> tags. NOTE: Only nl2br when you're grabbing data from the database. I do not recommend using nl2br when inserting data into the database. -
Wouldn't you be better of merging all the if/elseif's for the $sum_weight being 0.00 to 1.00 into just one? Seems pointless having 8 or so conditions that return the same result. Also rather than use || (or) use && (and) <?php function calculate_weight_and_postage($customers_country, $sum_weight) { // the 2 arguments we are taking are the customers country and the sum weight of the order print $sum_weight; // UK if ($customers_country == "United Kingdom") { // sub if if ($sum_weight > 0.00 && $sum_weight < 1.00) { $weightPostage = array("1.50" => "Standard - £1.50 incl VAT"); // return us the weight and postage to use return $weightPostage; } elseif ($sum_weight > 1.00 && $sum_weight < 1.10) { $weightPostage = array("2.95" => "Standard - £2.95 incl VAT"); // return us the weight and postage to use return $weightPostage; } else { $weightPostage = array("3.95" => "Standard - £3.95 incl VAT"); return $weightPostage; } return $weightPostage; } // UK } ?>
-
No need to install anything. You just write the necessary code for your BBCode parser. In order to write your own you'll need to know some basic PHP syntax and have an understanding of regular expressions.
-
You could of just used implode $query = "SELECT `name` FROM `table1` WHERE `name` IN('". implode("','", $array1) . "') ORDER BY CHAR_LENGTH(name) DESC"; Which will produce this query: SELECT `name` FROM `table1` WHERE `name` IN('Item0','Item1', etc) ORDER BY CHAR_LENGTH(name) DESC Using IN() instead name='name1' ORr name='name2' etc is more efficient.
-
preg_match error? Not able to get it???
wildteen88 replied to siddscool19's topic in PHP Coding Help
It would be helpful if you posted your code / regex pattern here too -
[SOLVED] how to fetch 4 lines from 20 lines of description
wildteen88 replied to vinpkl's topic in PHP Coding Help
This: echo "<td valign=top>". $row['detail_description'] . "</td>"; Needs to be echo "<td valign=top>". $desc . "</td>"; -
Oh! You're after BBCodes. There are many tutorials for adding BBCodes to your site.
-
PHPBB is a forum like this one here. Are you wanting to install a forum? PHPBB will install its own database.
-
[SOLVED] Why does php returning only one row of data?
wildteen88 replied to pneudralics's topic in PHP Coding Help
Your HTML code needs to be within your while loop otherwise only the last result will be displayed. <table width="800" align="center"> <tr> <td width="100%" align="center"> <?php //Website url $websiteurl = WEBSITEURL; //Retrieve gallery info $galleryselect = "SELECT * FROM gallery ORDER BY id ASC"; if ($galleryresult = mysql_query ($galleryselect)) { while ($row = mysql_fetch_array ($galleryresult)) { $gallery = $row['image']; echo '<img src="'.$websiteurl.'/images/gallery/'.$gallery.'" />'; } } ?> </td> </tr> </table> -
[SOLVED] how to fetch 4 lines from 20 lines of description
wildteen88 replied to vinpkl's topic in PHP Coding Help
Something like the following should do $sql = 'SELECT * FROM your_table'; $result = mysql_query($sql) or die('MySQL Error: ' . mysql_error()); while($row = mysql_fetch_assoc($result)) { $desc = short_description($row['description']); echo $desc; } function short_description($text, $max_lines = 4) { // standardize new lines $text = str_replace(array("\r\n", "\r"), "\n", $text); // get each line $lines = explode("\n", $text); // retieive the requires lines $list = array(); for($i = 0; $i <= $max_lines; $i++) { $list[] = $lines[$i]; } // add closing ul tag $list[] = '</ul>'; return implode("\n", $list); } -
phpBB is forum software. Got to phpbb.com for more info.
-
[SOLVED] how to fetch 4 lines from 20 lines of description
wildteen88 replied to vinpkl's topic in PHP Coding Help
In what format is the data in your description field, eg Format 1 Line 1<br />Line 2<br />Line 3 Or, Format 2 Line 1<br /> Line 2<br /> Line 3 Or Line 1 Line 2 Line 3 We'll need to know this in order for us to provide a suitable answer. -
[SOLVED] Quick question about database connection
wildteen88 replied to adamjones's topic in PHP Coding Help
Yes just specify the domain or the IP address for the mysql server you're wanting to connect to. -
Argh, Its your for loop that is the cause. Your post_values sessions variable is an associative array, however your using a number to access each item in the array. This is not possible. Instead your should use a foreach loop foreach($_SESSION['post_values'] as $field_name => $file_value) { if(empty($field_value)) $_SESSION['post_values'][$field_name] = ' '; }
-
Something must be going on in your code. Post your code here.
-
Use the SHOW DATABASES sql command to get all the databases that currently exist. Then use a while loop to loop through the available databases, eg $sql = 'SHOW DATABASES'; $result = mysql_query($sql) or die ('MySQL Error: ' . mysql_error()); $my_database = 'YOUR DATABASE NAME'; while(list($db_name) = mysql_fetch_row($result)) { if($db_name == $my_database ) { echo $my_database . ' exists!'; } }
-
Post your actual code here. The snippets you provided are fine. Maybe there is something else in your code that is causing it.
-
WAMP has phpMyAdmin configured for you. To access phpMyAdmin open the WAMP taskbar icon, this will open a context menu. From the menu choose PHPMyAdmin. A web browser should open showing phpMyAdmin.