-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
You need add the QSA flag to your rewriterule(s) RewriteRule ^blog/?$ index.php?action=blog [NC,L,QSA] RewriteRule ^blog/([A-Za-z0-9-]+)/?$ index.php?action=blog&name=$1 [NC,L,QSA]
-
How do I pull in different includes with a list of links?
Ch0cu3r replied to c_martini's topic in PHP Coding Help
Not possible without javascript (using an ajax request). PHP cannot react to events happening in the browser. It requires a HTTP request (thus a page load) in order for an action to be performed in your PHP code. -
In your Edit Record function you need to carry over the existing values of $_POST['editsel'] (record id) and $_POST['action'] (Edit Record). If you don't carry these values over in the edit record form the your code wont know what action to perform and what record needs updating when your submit the form for editing the record. So change the Edit Record form fields to print "<h1>Edit " . $title . "</h1>"; print "<input type='text' name='editassigndate' value='$assigndate' />"; print "<input type='text' name='editduedate' value='$duedate' />"; print "<input type='text' name='editpriority' value='$priority' />"; print "<input type='text' name='editcourse' value='$course' />"; print "<input type='text' name='editprof' value='$prof' />"; print "<input type='text' name='edittitle' value='$edittitle' />"; print "<input type='text' name='editdescription' value='$description' />"; print "<input type='hidden' name='action' value='Edit Record' />"; // <--- carry over the action (Edit Record) print "<input type='hidden' name='editsel' value='$editnumber' />"; // <-- what record needs updating print "<input type='submit' name='action' value='cancel' />"; print "<input type='submit' name='saveTable' value='save' />";
-
Only add Please enter your username and password to log in to $message when the form has not been submitted $message = "<span style=\"font-size:14px;\"><strong>Welcome </strong></span>!<br>"; if(isset($_POST['submit'])) { $errors = array(); $field_name = array('username','password'); if(empty($_POST[$field_name]) || !isset($_POST[$field_name])) { $errors[] = "Please enter a username or password"; } } else { $message .= "Please enter your username and password to log in"; // append this to $message (when form has not been submitted yet) }
-
Output $item["COUNTRY] into the image path echo '<img src="path/to/country/images/'.$item['COUNTRY'].'.png" />'; You can do he same thing for when you get the country code out of the database too.
-
session__register and session_is_registered are depercated. Do not use them. You use the $_SESSION variable adding data to the session. You use this variable like another variable. So when setting the myusername and mypassword session items you use $_SESSION['myusername'] = $myusername; $_SESSION['mypassword'] = $mypassword; To get the myusername and mypassword from the session use the $_SESSION['myusername'] and $_SESSION['mypassword'] variables, example echo 'myusername is: ' . $_SESSION['myusername'] . '<br />'; echo 'mypassword is: ' . $_SESSION['mypassword'];
-
Remove the float: left; from #container css definition. First increase the width or remove it ( width: 282px;) for #container css definition And then remove the float from #thumbnail and #info. Set them to display as inline. #thumbnail, #info { display: inline; } Change cleanString($title).cleanString($description) to cleanString($title) . '<br />' . cleanString($description) NOTE: When using CSS ids should be only be used once. You should be using classes instead.
-
You posted this in the wrong forum section. Should be PHP Coding Help. But I'll answer. First before the for loop add this $total = 0; Then in your for loop add $squared to the $total variable $total += $squared; Then after your loop you can echo $total to see sum of all the square numbers. Complete for loop code $total = 0; for ($i=$a+1; $i < $b; $i++) { $squared = $i * $i; echo ($i . "=" . $squared . "<br>"); $total += $squared; // add square number to $total } echo "Total: $total";
-
Text displaying as an image and text?
Ch0cu3r replied to lauren_etherington's topic in PHP Coding Help
If no image has been uploaded then what you'll see is the alt text ( alt='" . $tnrow['newstitle'] . "'). What want to be doing is only output the html code for the image if the news item has one. You'll want to change echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>"; to if(!empty($tnrow['newsimage'])) { echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>"; } -
How to pass variable to exec command in php script?
Ch0cu3r replied to shams's topic in PHP Coding Help
DId you even try the three examples I posted? exec ("echo 'My host name is $host'"); //OR exec ("echo \"My host name is $host\""); //OR exec ('echo "My host name is '.$host.'"'); -
How to pass variable to exec command in php script?
Ch0cu3r replied to shams's topic in PHP Coding Help
Ok. The problem with your code was the quotes exec ("echo 'My host name is $host'"); //OR exec ("echo \"My host name is $host\""); //OR exec ('echo "My host name is '.$host.'"'); -
It is most probably caused by other websites that is hosted on the same server as your site. This is the problem with shared hosting. If one site takes more traffic/resources then slow downs will happen to all sites hosted from the same server. The solution would be upgrade your hosting to dedicated hosting. That way you have control over the server.
-
How to pass variable to exec command in php script?
Ch0cu3r replied to shams's topic in PHP Coding Help
What do you need to use exec for? If you want to display what the user entered use. <?php if(isset($_POST['submit'])) { $host = $_POST['host']; echo "My hostname is $host"; } ?> <form mehtod="post"> Hostname: <input type="text" name="host" /> <input type="submit" name="submit" /> </form> -
What do you mean by that? Post the url you are using to opening the html and php file.
-
Change your PHP code to <?php $DBName ="fac90"; $DBConnect = mysql_connect("localhost", "fac90", "fac90") or die("<p>The database server is not available</p>"); mysql_select_db($DBName) or die("<p>The database is not available.</p>"); if(isset($_POST['facNum'])) { $facNum = $_POST['facNum']; $sqlquery = "SELECT * FROM teams WHERE facNum = '$facNum';"; $result = @mysql_query($sqlquery) or die ('<p> Error </p>'); $num_rows = mysql_num_rows($result); echo $num_rows; echo "<table width='100%' border='1'>"; echo "<tr><th>Room Num</th> <th> Name</th> <th>Department</th> <th>Materials</th> <th>Shipments</th> <th>Receivals</th> <th>Packing</th> <th>Location</th> <th>Reference</th> <th>Quantity</th> <th>Supplied by</th> <th>Phone</th> <th>Next Shipment</th> <th>Dates</th> </tr>"; while($Row = mysql_fetch_assoc($result)) { echo "<tr><td>{$Row['facNum']}</td><td>{$Row['Name']}</td> <td>{$Row['department']}</td><td>{$Row['materials']}</td> <td>{$Row['shipments']}</td><td>{$Row['rec']}</td> <td>{$Row['packing']}</td><td>{$Row['loca']}</td> <td>{$Row['Reference']}</td><td>{$Row['quant']}</td> <td>{$Row['supplied']}</td><td>{$Row['phone']}</td> <td>{$Row['NextShipment']}</td><td>{$Row['dates']}</td> </tr>"; } echo "</table>"; mysql_close($DBConnect); } ?>
-
The web browser encodes anything sent via GET or POST into what is known as percent encoding. I think at the same time it also decodes the htmlentities encoding into their original characters. This cause the htmlenitites values to be converted into the percent encoding equivalent. When PHP processes the POST data I believe it decodes the percent encoded POST request. So when you echo out the value from $_POST it is not htmlentities encoded anymore So you enter this into your form <div class="post"><b>data</b></div> When the form is first submitted you convert it to htmlentities, then add it to your forms field set its value to <div class="post"><b>data</b></div> When the form is submitted again the web browser will convert it to percent encoding %3Cdiv+class%3D%22post%22%3E%3Cb%3Edata%3C%2Fb%3E%3C%2Fdiv%3E Then you echo the data from $_POST you'll get the raw html back <div class="post"><b>data</b></div> Code I used for testing. <?php $text = isset($_POST['text']) ? $_POST['text'] : '<div class="post"><b>data</b></div>'; ?> <pre><?php echo $text; ?></pre> <hr> <form method="post"> Text: <textarea name="text" cols="20" rows="5"><?php echo htmlentities($text); ?></textarea> <input type="submit" value="submit" /> </form>
-
This is HTML <input type='text' name='keywords' size='60' value='companyname' maxlength='10' /> You cannot just dump that into your PHP code and expect it to work. I guess you want to make sure the company name is not more than 60 characters the PHP code would be if(strlen($_POST['companyname'] > 60)) { // company name is greater than 60 characters } Code for validating the companyname field would be if (empty($_POST["companyname"])) { $errors['companyname'] = "Please Enter Your companyname"; } elseif(strlen($_POST['companyname'] > 60)) { $errors['companyname'] = 'Company name must be less then 60 characters'; } elseif(stripos($_POST['companyname'], 'the')) { $errors['companyname'] = 'Company Names cant start with the'; } else { $companyname = test_input($_POST["companyname"]); }
-
Getting parent variable with php from child with iframes
Ch0cu3r replied to Noesis's topic in PHP Coding Help
You can use simplexml xpath for this $doc = new DOMDocument(); $doc->strictErrorChecking = FALSE; $html_source = file_get_contents('http://sitename,com/filename.php'); // url to webpage $doc->loadHTML($html_source); $xml = simplexml_import_dom($doc); $data = $xml->xpath("//a[@class='element_username']"); // finds <a href="..." class="element_username"></a> tags printf('<pre>%s</pre>', print_r($data, true)); // see what was found // echo username $username = (array) $data[0]; echo 'Username: ' . $username[0]; -
Getting parent variable with php from child with iframes
Ch0cu3r replied to Noesis's topic in PHP Coding Help
The only way you're going to get access to the variables set by the script is by including the raw PHP source code. If the PHP script is on a completely different site to yours then you are out of luck. Can you define what you mean by PHP variable? Are you wanting to get the username (Noesis) from the source code? (That you can do with PHP) -
That to me suggests$lineArray[5] is an array. Maybe you meant $lineArray is the array. Try array_unique($lineArray);
-
You'll want to pass $lineArray[5]; to array_unique $uniqueErrors = array_unique($lineArray[5]); var_dump($uniqueErrors); should display without duplicates
-
Because the text for the product descriptions is different it causing the price/readmore button to look out of positon. You just need to tweak your CSS now so the price/readmore button aligns to the bottom of the row. Probably want to add a min-hieight to the div that contains the product description text.
-
Your validateWetDry jhavascript function will have to loop through all forms named reserve and validate the water value for that field An easier way would be to change the function to function validateWetDry(target_form) { var water = target_form['water'].value; if (water==null || water=="0") { alert("Please tell us if you will need to use this unit wet or dry."); return false; } } And then change the onsubmit to return validateWetDry(this)
-
Oh my bad $results->fetchArray(); doesn't get all the results. it gets 1 row at a time. You need to change $data = $results->fetchArray(); foreach ($data as $result) to while($result = $results->fetchArray())
-
Your sites url is not being added t to the email this is the url I get in the email http://?action=view&id=1384869148 This is due to this line $link="http://${HTTP_HOST}${PHP_SELF}?action=view&id=$today"; This will only work if a setting called register_globals is enabled. Try and change it to $link="http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?action=view&id=$today";