-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
A query is defined within a string.All you do is concatenate the field/value pairs to the string to define the query. Once the query has been built you pass it to $db->query to execute it. // start to define the query $query = 'UPDATE parcels SET '; // now add the date_appeal_received field value if it is not null/empty if(!empty($date_appeal_received)) $query .= "date_appeal_received='$date_appeal_received', "; // now add the bos_meeting_datefield value if it is not null/empty if(!empty($bos_meeting_date)) $query .= "bos_meeting_date='$bos_meeting_date', "; // and so on // remove the comma after the last field/value pair $query = rtrim(', ', $query); // now add the where clause $query .= " WHERE parcel_id='$parcel_id'"; // Once the query has been built, execute it $result = $db->query($query);
-
Extracting GET variables from a string
Ch0cu3r replied to NotionCommotion's topic in PHP Coding Help
First use substr to get the query string (whatever is after the ?). Then pass the query string to parse_str $str='/index.php?g1=111&g2=222&g3=333'; $query_string = substr($str, strpos($str, '?')+1); parse_str($query_string, $array); printf('<pre>%s</pre>', print_r($array, 1)); -
It is because you have wrapped the date values within single quotes in your query here bos_meeting_date='". $date_appeal_received ."', <-- wrapped in single quotes late_returns_date='". $late_returns_date ."', <-- and here When your query is executed and the date values are null it will result in the query becoming bos_meeting_date='', <-- if the date value is null it will result in an empty value late_returns_date='', <-- same here If you do not want to add a value to a field if it is null (or empty) then do not include that field in your insert query. You should dynamically build the query. In your table schema make sure to apply DEFAULT NULL to those fields which do not require a value.
-
Using Variables in PHP.ini?
Ch0cu3r replied to random1's topic in PHP Installation and Configuration
According to the PHP documentation here you can use Windows Environment Variables within the php.ini -
Edit: Durp Did not see Barands reply @story97 the code provided by ginerjm in post #2 will include the name of the file that is in the url query string parameter named file. However in order for the code to function correctly you first need to whitelist the files that can be included, this is prevent a user from including any file. You do this by adding them to an array called $files_ar Example $files_ar = array( 'lesson1' => 'full/path/to/lesson1.html'; 'lesson2' => 'full/path/to/lesson2.html'; ...etc ); // followed by ginerjm code The url for including lession1.html will be site.com/your_page.php?file=lession1 this will then include the file lession1.html
-
No. You do not need to unhash the users password. This is not how you handle logins. Passwords should be stored as hashes in the database, they should not be stored as plain text. When the user submits the login form you hash the password they entered. You then query your accounts table to return the record where the username and password hash matches. If the a record is returned then the user is authenticated.
-
I assume the array you posted is the contents of $data? To get the name and state you loop over the $devices array and then grab the name and state items from the sub array. Example foreach($devices as $device) { echo $device['name'] . ' ' . $device['state'] . '<br />'; }
-
Moved to Third Party Scrips forum. _e is not a PHP function. It is a function defined by Wordpress for translating/outputting text. To format it you need to modify the HTML surrounding this block of code <?php _e('No products found','woocommerce'); ?>
-
You are getting the ip address line repeated because the code that outputs it is within a foreach loop. It will output the ipaddress for every file within the images/flags/ directory. There is no need for the foreach loop
-
Only skimmed through the code but I found these issues. On Line 11 you have an malformed echo statement. Which is not needed. On line 16 you need to escape the double quotes within your double quoted string On line 98 you have placed some random HTML. It needs to be echoed
-
Warning: mysql_fetch_assoc() expects parameter 1 to be resource
Ch0cu3r replied to ryuvely's topic in PHP Coding Help
Usually this type of error means your mysql query failed due to an error. You can use mysql_error to find out why its failing. Change lines 44 and 45 in services.php to the following $result=$employee->getEmployees(); // if the query executed if($result) { $employee->showHtmlEmployees($result); } else { // lets find out why the query failed trigger_error('Cannot get Employees from database: ' . mysql_error()); } Please note when posting code wrap it within tags (or click the <> button in the editor) -
Where you use $StudentInfo->student_guardian_occupation_address <td class="label">BODY</td><td colspan="3"><?php echo nl2br($StudentInfo->student_guardian_occupation_address);?></td>
-
Your query is fine. The problem is here //This bit definitely ain't right $p1 = $row['level']; $p2 = $row['level']; $p3 = $row['level']; You need to use P1, P2, or P3 in place of level. Example $p1 = $row['P1']; $p2 = $row['P2']; $p3 = $row['P3'];
-
No! requinix already explained mod rewrite cant do that that (in reply #2) The substitution needs to take place in your PHP code. The place you need to edit is where it outputs the urls to yoursite.com/user/.../cake/...
- 6 replies
-
- htaccess
- mod_rewrite
-
(and 1 more)
Tagged with:
-
Before you start using mod rewrite you need to get yourself familiar with regular expressions (regex for short) as this is what is used for the rewriteRules. regular-expressions.info is a good resource for learning regex As for learning mod rewrite I recommend you looking at Apaches documentation first. When I first starting using mod rewrite I used this guide here.
- 6 replies
-
- htaccess
- mod_rewrite
-
(and 1 more)
Tagged with:
-
Some help needed about one variable in different links
Ch0cu3r replied to 684425's topic in PHP Coding Help
By using $_GET['r] You will do another if/else statement to include the appropriate file. You maybe better of creating a function so you pass $_GET['x'] and $_GET['r'] to it and it returns the path to the file(s) to be included. -
The mod_rewrite Apache module as a basic requirement
Ch0cu3r replied to Maze's topic in Apache HTTP Server
Looking at your other topics your server uses OpenSuse right? You need to enable the rewrite module in apache's config as it is not enabled by default. Check this guide for instructions. http://enarion.net/web/htaccess/mod_rewrite-on-suse/ Wordpress uses mod_rewrite for clean SEO urls. -
How to use micro time efficiently and correctly?
Ch0cu3r replied to Monkuar's topic in PHP Coding Help
Locked. Do not post multiple topics for the same question/problem. Continue where you left off from your previous topic -
You could of answered that question yourself by looking at the php documentation for the functions used in the code you posted.
-
Make sure you have restarted the Apache service after you had made changes to its configuration Is the other application Skype? You can tell it not to use port 80 within the options menu. No. This will only be a problem if you are going to accessing your localhost site remotely (In other words hosting your website from your computer).
-
Try <td class="table-cell-title">NARRATIVE</td> <td class="table-cell-content"> <?php echo (!empty($studInfo->Rel_Stud_Info->student_guardian_occupation_address) ? nl2br($studInfo->Rel_Stud_Info->student_guardian_occupation_address) : "Not Set"); ?></td>
-
It would be better to alter your query to only return the images that have not expired yet SELECT image_id, image_expiry FROM images WHERE image_expiry > CURDATE() ORDER BY RAND() LIMIT 10
-
Then remove these lines header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename="' . $FileName . '"'); echo $Content; exit(); Those lines will force the file to be downloaded. To write your data to a csv file then look into using fputcsv
-
You use nl2br when you go to output your data. Small example <?php if(isset($_POST['submit'])) { echo nl2br($_POST['my_data']); // output data entered into textarea echo '<hr />'; } ?> <form method="post"> <textarea name="my_data" rows="10" cols="100"><?php echo isset($_POST['my_data']) ? $_POST['my_data'] : ''; ?></textarea> <input type="submit" name="submit" value="Submit" /> </form>