wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
What browser are you using? Tested with FF, IE7 and Safari
-
Strange, doesn't for me. I changed your HTML and JavaScript.
-
<a href='javascript:void(0);' onclick='dispForm()'>Click here</a><br /> <form id="formA" action="" method="post" style="display:none"> <input name="test_box" id="test_box" type="text" size="10"> <br /> <input name="sub" type="submit" value="submit"> </form> <script> function dispForm () { var tehForm = document.getElementById('formA'); tehForm.style.display = "block"; } </script>
-
You can change the port Apache uses to any port that is available, for example port 8080. To do so make sure WAMP has stopped. Now find Apaches httpd.conf file that WAMP uses. Find the following line Listen 80 (note: It may differ slightly). Change the number 80 to 8080 Save the httpd.conf. Now start WAMP. As you have changed the port WAMP listens on you cannot use http://localhost to access WAMP. Instead you have to use http://localhost:8080 NOTE: the port number MSUT be present in the url.
-
Your host is right, your script reply's on old outdated coding techniques as it requires register_globals to be enabled. register_globals is now disabled by default and is soon to be removed completely as of PHP6. You should use superglobal variables instead A basic run down of the variables, $_GET - receive variables from the url, example variable $_GET['foo'], example url yousite.com?foo=bar $_POST - used to access POST data once a form has been submitted, example $_POST['your_field_name'] $_COOKIE - receive a cookie values, eg $_COKIE['cookie_name'] $_SESSION - all session data is set within this variable, $_SESSION['var_name'] $_SERVER - receive a server declared variable, eg $_SERVER['PHP_SELF']
-
[SOLVED] Installing zend zend framework (include_path confusion)
wildteen88 replied to Derleek's topic in Frameworks
You'll find it a lot simpler if you add the following to your bootstrapper file (index.php) // modify the include_path set_include_path('users/zend/library' . PATH_SEPARATOR . get_include_path()); -
I don't want to rename the file, just rename it on that list. I presume you mean you don't want the index.php file displayed in the generated list. You should do this instead: <?php $handle = opendir("."); $ignore_files = array('.', '..', 'index.php'); while (($file = readdir($handle))!==false) { // do not display files listed in the ignore_files array if(!in_array($file, $ignore_files)) { echo $file . '<br />'; } } closedir($handle); ?>
-
Not sure but from this article yor can restart IIS from IIS Manager or via the commandline using the IISReset command.
-
You cannot add a newline (<br />) between two table rows. You should apply padding/margin to the required row(s) instead, eg change print "<tr class='mainrow'><td>Military</a></td></tr>"; to print "<tr class='mainrow header'><td>Military</a></td></tr>"; Now apply the following style in your CSS tr.header { margin-top: 20px; padding: 0; }
-
You saying libmysql.dll is not found within your PHP Installation folder? If that is case the mysql extension will not function without it. I recommend you to download the zipped binaries package. Once the zip has downloaded extract the contents of the zip to where you have PHP installed. Making sure you overwrite existing files/folders. libmysql.dll should now be available, restart IIS. Check whether mysql is available by phpinfo. I do not recommend the PHP installer, It is best to do all configuration by hand.
-
One of you if doesn't have a closing brace (notably the first one).
-
Because mysql_fetch_array returns duplicate results as it contains both a numeric array ($row[0]) and an associative array ($row['field_name']). Change mysql_fetch_array to mysql_fetch_assoc (or to mysql_fetch_row) instead.
-
Ohh, after re-reading the post I think you are right. @IronWarrior ignore my post. The problem you're having is to do with the web browser ignoring newlines in your formatted text. To prevent this you need to convert the newlines in your text to a line break tag (<br />). This can be achieved by using a built in function called nl2br. You should use this function when you retrieve data from your database only. Example $sql = 'SELECT * FROM your_table'; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { echo nl2br($row['your_field_with_formatted_text']); } nl2br should not be used when adding data to the databases, as you may find your newlines duplicate each time you edit the text.
-
Could you explain how those two arrays ($div and $divText) are created. Or are they hard-coded? You should be able to accomplish this by a standard foreach loop: $div[] = array("Title" => "1", "Link" => "http://blablabla.com", "Image" => "image.jpg"); $div[] = array("Title" => "2", "Link" => "http://foobar.com", "Image" => "image2.jpg"); $divText = array("1" => "text 1", "2" => "text 2"); foreach($div as $key => $arr) { echo '<div> <span class="title">'.$arr['Title'].'</span><br> <a href="'.$arr['Link'].'" target="_blank">link</a> <img src="'.$arr['Image'].'" alt="Death Race"><br><br> <span class="text">'.$divText[($key+1)].'</span> </div>'; }
-
That's because you should escape the square brackets ( '[' and ']' ). Also it is pointless using preg_replace if you're not using regex within your patterns. This is how I'd do bbcodes: function bbcode($string) { $search[0] = '#\[p\](.*?)\[/p\]#ies'; $search[1] = '#\[u\](.*?)\[/u\]#is'; $replace[0] = "'<p>'.nl2br('$1').'</p>'"; $replace[1] = '<u>$1</u>'; return preg_replace($search, $replace, $string); } $text = '[p]Paragraph 1[/p] [p]Paragraph 2, with [u]Underline![/u][/p] [p]Paragraph 3, keeps newlines![/p]'; echo bbcode($text);
-
Just change code within the while loop, eg $sql = 'SELECT preferred_subject, count(preferred_subject) as subject_total FROM students GROUP BY preferred_subject'; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { echo $row['preferred_subject'] . '(' . $row['subject_total'] . ')<br />'; } That would be possible if you stored your subjects in a separate table, then you'd use a JOIN to query the two tables at once. Example table structure [pre] subjects ---------- students id -------------+ ---------- subject | ... your current fields ... +-- preferred_subject[/pre] Now if your tables where setup like that, you'd store the id of subject in the preferred_subject field (instead of the actual subject name). Then using a simple JOIN: SELECT s.subject as pref_subject, COUNT(s.subject) as total_subject FROM subjects s, students st WHERE s.id = st.prefered_subject GROUP BY s.subject Should produce a list like maths (1) english (3) french (1) physics (0) ... etc ...
-
CV meant use the GROUP BY statement in your query, eg $sql = 'SELECT preferred_subject, count(preferred_subject) as subject_total FROM students GROUP BY preferred_subject'; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { echo '<pre>' . print_r($row, true) . '</pre>'; }
-
how do I access and edit variables of another php file
wildteen88 replied to phplearner2008's topic in PHP Coding Help
Your saving FORM and TO to the database, why don't you run a sql query in the interests_sent.php to retrieve these instead, eg $sql = "SELECT FROM, TO FROM interests_sent ORDER DESC LIMIT 1"; $result = mysql_query($sql) or die("Query: " . $sql . "\n\n" . mysql_error()); list($FROM, $TO) = mysql_fetch_row($result); echo $FROM . ' - ' . $TO; -
Before enabling any extensions within the php.ini make sure you done the following first 1. Open your php.ini and set up the extension_dir directive to point to PHP's extension folder (eg extension_dir = "C:/php/ext") 2. You're restarting your server (by this I mean software, not hardware eg IIS, Apache etc) when ever you change the php.ini. 3. Run phpinfo and make sure PHP is reading the php.ini you're modifying. To check this look for the Loaded Configuration File line. This should be set to the full path to the php.ini PHP is reading. As you have added PHP to the PATH, your php.ini should be in the root of your PHP installation folder. NOTE: Ignore the Configuration File (php.ini) Path line above if its set to C:\WINDOWS (this is not where your php.ini needs to be). Step three is the most important, if step three fails then you wont be able to configure PHP. If PHP is reading your php.ini try uncommenting the mysql extension line ;extension=php_mysql.dll (remove the ; at the start of the line). Then repeat step 2 above. Confirm the extension is loaded by running phpinfo and looking for a MySQL subheading. Also note that the mysql extension does not reply upon a local install of MySQL. However it does reply on the mysql client though, this comes with PHP in the form of libmysql.dll
-
Your form is correct, and your PHP code. You're not at fault. This has to be some form of server configuration issue (which is out of your control). You should have a word with your host about this. As a test what happens if you create a new script and run it: <?php echo 'PHP works!'; ?> Do you get the same error? If you do then it is definitely a server configuration issue.
-
Its because your html is incorrect. Remove the highlighted code above. What I'd apply is apply a class (eg: <ul class="inline">) to the first ul tag, and apply the following css #sidebar ul.inline { display: inline; }
-
use a ternary operator $page['text']='<table width="100%" border="0" cellpadding="2">' . "\n<tr> <td width=\"7%\"><a href=\"&s=" . (($sort==0) ? 1 : 0 ). "\">ID</a></td> <td width=\"19%\"><a href=\"&s=" . (($sort==2) ? 3 : 2 ) . "\">Name</td>
-
I think this is more of a server configure issue. How is PHP setup on the server, or are you using a host?
-
fopen will attempt to create the file if it doesn't exist, it shouldn't overwrite the file. In order for this to happen you should use the appropriate mode parameter for fopen. As a side note, matthew798 code is valid it should append the string "Bobby Bopper\n" to YOURFILE.txt each time the page loads. If its not working correctly then may be its a file permission problem.
-
Yes it will still work. it is simply a way to have apache map one url to another. eg; http://yourdomain.com/foo/bar -> http://yourdomain.com/index.php?section=foo&article=bar Yes that makes sense, but ... how does apache know the difference between something it needs to "map" opposed to accessing a file called "bar" in directory "foo". You'd do this by setting up a rewrite conditions to check to see if the requested url is not a existing file/directory, example RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # your RewriteRule's continue here