ignace
Moderators-
Posts
6,457 -
Joined
-
Last visited
-
Days Won
26
Everything posted by ignace
-
Open the file in an hex editor and post the hex that end each line.
-
Make sure year is of type YEAR: 'INSERT INTO gallery_category (category_name, Year) VALUES (' . addslashes($category_name) . ', ' . $year . ')'
-
header("Content-Type: text/html; charset=ISO-8859-1"); <input type="Content-Type" content="text/html; charset=ISO-8859-1">
-
An object can contain an instance(s) of itself.
-
strtolower() are you sure?
-
$CAPITAL_MD5 = strtoupper($MD5);
-
What does this give you? print_r(file($file));
-
No. It should be: if(isset($_POST['submit']) && !empty($_POST['textarea'])) { echo "okay"; } else { echo "wrong"; }
-
print_r($_POST); verify everything you need is posted. You don't need them anyhow as they are doing nothing. $status = "$name added to database!"; $name is an array with a key and null as a value as defined here: if(!isset($_POST['name'])) $name['name']/* $name = array ( 'name' => null ) */; <?php $hostname = ""; $database = ""; $username = ""; $password = ""; $PHP_SELF = !isset($PHP_SELF) ? $_SERVER['PHP_SELF'] : $PHP_SELF; $action = !empty($_POST['action']) ? $_POST['action'] : NULL; $status = !empty($_POST['status']) ? $_POST['status'] : NULL; $find = !empty($_POST['find']) ? $_POST['find'] : NULL; $name = !empty($_POST['name']) ? $_POST['name'] : NULL; $age = !empty($_POST['age']) ? $_POST['age'] : NULL; function escape($string) { if(get_magic_quotes_gpc()) $string = stripslashes($string); return mysql_real_escape_string($string);//only works if their is a db connection available. } mysql_connect($hostname, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); switch($action) { case "add": mysql_query("INSERT INTO example (name, age) VALUES('".escape($name)."', '".escape($age)."' )") or die(mysql_error()); $status = "$name added to database!";//overwrites the previous declared $status break; case "del": mysql_query("DELETE FROM example WHERE name='".escape($named)."' ") or die(mysql_error()); $status = "$named removed from database!";//overwrites the previous .. break; case "search": /*mysql_query("SELECT * FROM example WHERE name='%".escape($find)."%' ") or die(mysql_error());*/ $query = mysql_query("SELECT * FROM example WHERE name LIKE '".escape($find)."' ORDER BY name"); while ($row = mysql_fetch_array($query)) { echo $row['name']; echo "<br/>"; } break; } ?> <html> <head> <title>MySQL/PHP</title> </head> <body> <?php echo "$status"; ?> <br/> Add Entry in Database: <form method="post" action="<?php echo $PHP_SELF ?>"> Name: <input type="text" size="25" maxlength="50" name="name"><br/> Age: <input type="text" size="5" maxlength="3" name="age"><br/> <input type="hidden" value="add" name="action"> <input type="submit" value="Submit"> </form> Delete Entry from Database: <form method="post" action="<?php echo $PHP_SELF ?>"> Name: <input type="text" size="25" maxlength="50" name="named"><br/> <input type="hidden" value="del" name="action"> <input type="submit" value="Submit"> </form> Search Entry from Database: <form method="post" action="<?php echo $PHP_SELF ?>"> Name: <input type="text" size="25" maxlength="50" name="search"><br/> <input type="hidden" value="find" name="action"> <input type="submit" value="Submit"> </form> </body> </html>
-
$years = range(1900, 2009); P.S. w00t! 1000 posts almost a grown-up now
-
Question on OOP / MVC design structure: SubClass for DB activity
ignace replied to FarhanKhalaf's topic in PHP Coding Help
require_once() has nothing to do with http requests. What you actually mean is that you are lazy loading the file. These belong in the models (and don't use wrapper's, you are only limiting the object you are wrapping). I am not entirely sure wether I should say yes or no. A front-controller uses a router to route a request (http, ftp, ..) to a controller and it's action. In the action are/is a certain model(s) (wether db or file) called, wrapped (view doesn't need accessor functionality) and passed to the view which handles the proper rendering wether it's html, xml, json or plain text. Everyone always said: skinny controllers, fat models. Nowadays they are even saying: skinny models, fat service layers. A service layer is based on a use-case and can be something like: $userService->registerUser($request); -
http://us2.php.net/manual/en/function.nl2br.php
-
These lines do nothing (well the body I mean): if(!isset($_POST['find'])) $find['find']; if(!isset($_POST['named'])) $named['named']; if(!isset($_POST['name'])) $name['name']; if(!isset($_POST['age'])) $name['age']; Note the use of %: $query = mysql_query("SELECT * FROM example WHERE name LIKE '%".escape($_POST['find'])."%' ORDER BY name");
-
However then I would advice modifying window.location.hash = 'page' on every new page load.
-
I would advice to work with certain states so a review may be PENDING (or NEW), HOLDING, APPROVED or ARCHIVED. A new review would have the state PENDING and could get the state HOLDING (multiple reviews may come in and you want to pick the better one) after PENDING or HOLDING a review can change state to APPROVED (published to the website) only APPROVED reviews will be archived after some time. You can automate the archiving process by adding a archive_date column to your table. When the date is hit, the review state is changed to ARCHIVED.
-
Apparently it appears that their isn't an actual accurate algorithm to convert cmyk to rgb as pointed out by: http://developer.loftdigital.com/blog/cmyk-rgb-and-php
-
I must warn you though that by disallowing the use of the enter key will decrease the usability of your website as most people are used to tab between fields and use arrow keys to select if multiple selective options are available and use the enter key all without touching the mouse. I would find it annoying to find out that I need to use my mouse and that when pressing enter nothing appears to happen as this is accepted as "normal" behavior.
-
Help with sending an array variable from page to page
ignace replied to Darkmatter5's topic in PHP Coding Help
$serialized = serialize($names); $unserialized = unserialize($serialized); Another option would be storing the _POST values: $_SESSION['_POST'] = array_merge($_SESSION['_POST'], $_POST);//merges the new _POST with the already existing values. Note: if key exist in _SESSION[_POST] it will be overwritten -
Use: <button type="button" onclick="return onClick_validateForm();">Submit</button><!-- returns false if invalid else return true --> Instead of: <input type="submit">
-
What does this Piece of PHP codes do?
ignace replied to natasha_thomas's topic in Third Party Scripts
The first script loads an iframe and as a src it defines r-decode with some parameter. Now once the page loads the src is read and the php code inside r-decode executed. If it is a bot they are redirected to their loopback address. -
WHERE assignment LIKE '%$assignment%'
-
php uses smtp to send e-mail. However it is possible to send e-mails from php using your gmail, hotmail, yahoo account. http://www.phpclasses.org/blog/package/9/post/1-Sending-email-using-SMTP-servers-of-Gmail-Hotmail-or-Yahoo-with-PHP.html
-
[SOLVED] Proper syntax to dynamically generate lines of code
ignace replied to imimin's topic in PHP Coding Help
mysql_real_escape_string() won't work if a connection to the database hasn't yet been established. I know that but that wasn't to what I was referring. $cat = isset($_GET['cat']) ? $_GET['cat'] : 'all'; He uses $cat='all' and nowhere in his code does he retrieve the value from _GET. akitchin uncommented the line $cat = mysql_real_escape_string($_GET['cat']) (weird to point me then with a finger ) and he commented it again and left $cat='all' uncommented.