wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
You need to echo the <option></option> HTML tags within the for loop: <?php echo "Table '$dbname' in database '$database'"; echo "<body text=\"#0033FF\"> <form name=\"form1\" method=\"post\" action=\"\"> <label> <select name=\"select\">\n"; for ($index=0; $index < $number_fields; $index++) { $field = mysql_field_name ($result, $index); echo " <option value=\"$field\">$field</option>\n" } echo ' </select> </label> </form>'; ?>
-
Because you are including files using the http:// protocol within the include function PHP will parse the code in those files separately and only return the output, it wont use variables which you set within the main script Use relative paths instead, change: <?php $section = 'home'; ?> <?php include ("http://leonpaternoster.com/inc/header.php"); ?> <?php include ("http://leonpaternoster.com/inc/navbar.php"); ?> to: <?php $section = 'home'; define('ROOT', $_SERVER['DOCUMENT_ROOT']); include ROOT. '/inc/header.php'; include ROOT. '/inc/navbar.php'; ?> You'll also need to change the last two includes to: <?php include ROOT. '/inc/right-col.php'; include ROOT. '/inc/footer.php'; ?>
-
It certainly can, all you need to do is call the search() function fo each keyword entered in the search box. You'll need to use Javascript for that.
-
Search doesnt searchs in the code posts and, ads.
wildteen88 replied to mudi's topic in PHPFreaks.com Website Feedback
We do use Google Adsense as revenue to keep this community alive however due to the extreme advents that happened here for the past week or two, the admins have not got round to adding the mods back into the forum as yet. Currently the admins highest priority is to relaunch the main site. There are some big plans in place so stay tuned. -
If you want the search box on the html page then you can copy the form code over to your html page, set the action attribute in the form tag to search.php, eg: <form action="search.php" method="post"> Search word: <input type="text" name="keyword" /> <input type="submit" name="submit" value="Search" /> </form> When the form is submitted the browser will load search.php displaying the results.
-
Newbie Here:Help in Installation in PHP
wildteen88 replied to jpacs's topic in PHP Installation and Configuration
Advantage of installing AMP stack manually would be you get to learn how to configure them and to upgrade each component easily. Disadvantage would be can get frustrating when it doesn't work. Advantage of installing a pre-configured AMP stack such as WAMP, is that it's all ready to go. Disadvantage you don't get learn how to configure the AMP stack. Upgrading individual component can be tricky and they tend to come with a lot of bloated added features. -
As in a hyperlink? <a href="search.php">Search</a> Or type go to it manually: http://yoursite.com/search.php Change search.php to the name of your actual .php file.
-
Where did the file go to? And a few other silly questions.....
wildteen88 replied to dicky96's topic in PHP Coding Help
Simply use the tags -
Read the manual before asking questions on comparison operators.
-
Sounds like a problem with the datatype for the comments field. What datatype is it set to within your database structure It sounds like it is set to VARCHAR. VARHAR can only hold a maximum of 255 characters change the field type to TEXT instead.
-
You need to save the code within a .php file and not a .html file. Make sure your hosting account supports php.
-
Huh, don't understand you there, why is the code in one line? What errors are you getting? If code is being displayed then something is wrong with your PHP installation.
-
You need to escape the ] brackets too. (\])
-
Something like this: <?php function search($keyword) { $results = false; $lines = file('search_data.txt'); // escape characters which are sensitive to eregi() $symbols = array('[', ']', '-', '(', ')'); $replace = array('\[', '\]', '\-', '\(', '\)'); $keyword = str_replace($symbols, $replace, $keyword); foreach($lines as $line) { if(eregi($keyword, $line)) { $line = str_replace($keyword, "<b>$keyword</b>", $line); $results[] = $line; } } return $results; } if(isset($_POST['submit'])) { if(!empty($_POST['keyword']) && strlen($_POST['keyword']) > 3) { $keyword = $_POST['keyword']; $search_results = search($keyword); if(is_array($search_results)) { echo 'The search term "<i><b>'. $keyword . '</b></i>" found ' . count($search_results) . ' search result(s):'; echo '<ol><li>' . implode('</li><li>', $search_results) . '</li></ol>'; } else { echo 'No results was returned'; } } else { echo 'Invalid search term "<i><b>'. $_POST['keyword'] . '</b></i>"'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Search word: <input type="text" name="keyword" /> <input type="submit" name="submit" value="Search" /> </form> search_data.txt is the file which contains your search data.
-
Because you have your flash banner in every page it is always going to reload on every page request. It has nothing to do with PHP. There is not a definite way to stop the reloading, one of the tricks I used to do is use an HTML frameset. In the top frame you'll have the flash banner and the bottom frame you'll have your site. That way when you go to different pages in your site the flash banner doesn't get reloaded all the time, only your site content. However a more modern way would be to use AJAX instead rather than a frameset. As your banner is very basic and not much happens, only the fancy animations during loading/mouseover's. Another idea would be to just show your flash banner for the index page and then just a static image for the rest of the pages and redo your grey menu bar in just plain HTML/CSS.
-
I can't retrieve a matching password from MySQL
wildteen88 replied to djw821's topic in PHP Coding Help
What size is the password field. The MySQL PASSWORD() function returns an encrypted string which is 41 characters long. Make sure your password field datatype is set to VARCHAR and the length is set to atleast 41 bytes or higher. -
That technique is called Breadcrumb, search google for that term and you should find some scripts/tutorials.
-
Post some example data from the text file and the result you'd like.
-
Where did the file go to? And a few other silly questions.....
wildteen88 replied to dicky96's topic in PHP Coding Help
Yes you will need to create the folder htdocs/test/upload Argh sorry. This bit I forgot to mention. When using a backslash (\) in your scripts always escape them unless you are escaping another character, so this line should be: echo file_exists("c:\\temp\\upload\\".$_FILES["file"]["tmp_name"]); Have a read of the following about escape sequences -
EDIT: Too slow beaten to it Build the query dynamically, eg: if(isset($_POST['submit'])) { if(!empty($_POST['name']) && trim($_POST['name']) != '') { $name = ($_POST['name']); $where_clause[] = "name='$name'"; } if(is_numeric($_POST['phone']) && trim($_POST['phone']) != '') { $phone = $_POST['phone']; $where_clause[] = "phone='$phone'"; } if(!empty($_POST['addr']) && trim($_POST['addr']) != '') { $addr = ($_POST['addr']); $where_clause[] = "addr='$addr'"; } if(!empty($_POST['city']) && trim($_POST['city']) != '') { $city = ($_POST['city']); $where_clause[] = "city='$city'"; } if(!empty($_POST['zip']) && trim($_POST['zip']) != '') { $zip = ($_POST['zip']); $where_clause[] = "zip='$zip'"; } if(is_array($where_clause) && count($where_clause) != 0) { $wc = 'WHERE ' . implode(' AND ', $where_clause); } $query = 'SELECT * FROM contacts ' . $wc; echo '<pre>' . $query . '</pre>'; }
-
Try: <?php function get_paragraphs() { $lines = file('data.txt'); $cur_pgraph = null; $paragraph = array(); foreach($lines as $line) { #$line = trim($line); if(eregi("^\[([a-z0-9\-_ ]+)\]", $line)) { $cur_pgraph = trim(str_replace(array('[', ']'), '', $line)); $paragraph[$cur_pgraph] = null; } else { $paragraph[$cur_pgraph] .= $line; } } return $paragraph; } if(isset($_POST['submit'])) { $output = null; foreach($_POST['paragraph'] as $data) { $title = $data['title']; $content = $data['content']; $output .= "[$title]\n$content\n"; } file_put_contents('data.txt', $output); header('Location: ' . $_SERVER['PHP_SELF']); } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" cellpadding="5" cellspacing="1"> <tr> <th colspan="2"><h1>Paragraph Editor</h1></th> </tr> <tr> <th width="150">Title</th> <th>Content</th> </tr> <?php $i = 0; foreach(get_paragraphs() as $key => $data) { echo " <tr valign=\"top\">\n <td><input type=\"text\" name=\"paragraph[$i][title]\" value=\"$key\"></td>\n ". "<td><textarea name=\"paragraph[$i][content]\" cols=\"60\" rows=\"6\">$data</textarea></td>\n </tr>\n"; $i++; } ?> <tr> <td colspan="2"><input type="submit" name="submit" value="Apply Changes" /></td> </tr> </table> </form> <?php } ?> change data.txt to the name of the file that contains your paragaphs
-
Need to see more code then, specifically the code that includes inc/navbar.php
-
Strange that should work. Is any errors displayed?