
PeoMachine
Members-
Posts
52 -
Joined
-
Last visited
Everything posted by PeoMachine
-
Give us the code or the link of that page, please.
-
Need advice on a clean way to handle custom errors.
PeoMachine replied to atrum's topic in Application Design
You can try to use different types of Exception. You use a "User_Exception" if you have invalid input data or something like that, and a "Database_Exception" for great errors, like loose connection. It can be like this: try { $newUser = new User(); $newUser->setCredentials('user', 'pass'); $newUser->insert(); } catch (Database_Exception $e) { // log this error // stop the script } catch (User_Exception $e) { // Display the error } -
PHP Forced download not working correctly
PeoMachine replied to Mitchey-Welch's topic in PHP Coding Help
Try to send a header with "Content-type"... something like: header('Content-type: application/pdf'); -
Post your htaccess. Maybe the problem is with him.
-
I like Sublime Text (http://www.sublimetext.com/). Has a good code highlight, good autocomplete, is thin and beautiful.
-
change this: $html_output .= "<option selected="; if(isset($_POST['submit'])) { if($_POST['date_year'] == $year) { $html_output .= "\"selected\""; } } $html_output .= ">". $year . '</option>'."\n"; for this: $html_output .= "<option "; if(isset($_POST['submit'])) { if($_POST['date_year'] == $year) { $html_output .= "selected=\"selected\""; } } $html_output .= ">". $year . '</option>'."\n"; Just print "selected=" if you want the option active. You are printing "selected" on all of them. And you can write this way too: $selected = ''; if(isset($_POST['submit']) && ($_POST['date_year'] == $year)) $selected = 'selected="selected"'; $html_output .= "<option $selected>$year</option>\n";
-
unexpected T_CONSTANT_ENCAPSED_STRING
PeoMachine replied to homeflair's topic in Third Party Scripts
Are you sure thats the right file? I didnt see anything wrong. -
php display css with order, 1/2/1/2/1/2/1/2 etc...
PeoMachine replied to anthelo's topic in PHP Coding Help
What do you have? An result of a select? A finite loop? ... -
You are sending these photos by email? If yes, the problem is the email client. If not, post the code to us.
-
Your relation is: Album has many photos. Right? Your album class should have an structure to store your photos, maybe an array or something like that. class Album { private $id; private $name; private $description; private $photos = array(); }
-
Submit a form with a radio button choice
PeoMachine replied to GoogleBoss's topic in PHP Coding Help
On that case, you can treat the selected radio and redirect, or put the site on the value of the radio. 1) <?php switch($_POST['payment_method']) { case 'paypal': $redirect = 'www.paypal.com'; // the others } header("Location: {$redirect}"); 2) <label><input type="radio" name="payment_method" value="www.paypal.com" /> Paypal </label> // The PHP does that <?php header("Location: {$_POST['payment_method']}"); -
Page not found within a redirected page
PeoMachine replied to gerkintrigg's topic in PHP Coding Help
I think the path to the file is wrong. Your login page (login.php) in on the root folder ? If yes, when you call the ajax, try to pass '/login.php' instead 'login.php'. -
You can use a div, manipulating this with Jquery.
-
Submit a form with a radio button choice
PeoMachine replied to GoogleBoss's topic in PHP Coding Help
You can do a page with the three options in radio buttons. When you submit this form, you can search for the informations on the database... for example: $sql = "SELECT site FROM payment_method WHERE method = '$_POST['payment_method']'"; $stmt = $database->query($sql); $method = $stmt->fetch(PDO::FETCH_OBJ); header("Location: {$method->site}"); It will redirect you to the correspondent site... Or you can just put the site on the value of the radio button and redirect when the form is submited. -
Form with multiple fields with the same names.
PeoMachine replied to Ryflex's topic in PHP Coding Help
I couldnt understand what you need... In your form you will create 2 arrays with theirs keys numerics ($name and $link). You want to do one array with the two informations? Something like that: $menu = array( 0 => array( 'name' => 'Menu Name', 'link' => 'Menu link', ) ); If yes, you can do something like that: <?php // your other stuff here while($row = $sql->fetch()) { echo "<li id='listItem_".$row['id']."'> <img src='images/arrow.png' alt='move' width='16' height='16' class='handle' /> <input type='text' name='menu[".$row['id']."][name]' value='".$row['name']."' /> <input type='text' name='menu[".$row['id']."][link]' value='".$row['link']."' /> </li>"; $n++; } ?> -
Strange Layout (Ignoring then Reading DIV Close)
PeoMachine replied to justlukeyou's topic in PHP Coding Help
Have you tryed to show the PHP Errors? The only problem i can see is in the database incoming data, your PHP looks fine. -
What you're trying to do? You can use the uniqid function.
-
i didnt understand what youre trying to do... if you wanna unset all in the 'cart' index, just do a $_SESSION['cart'] = array();
-
You can do a Trigger on the database... http://en.wikipedia.org/wiki/Database_trigger
-
Stacking Images and revealing the bottom image
PeoMachine replied to coinpusha's topic in Javascript Help
Try to use Jquery. -
I dont know if i understood... you dont know how to name and organize your classes. I'm right? If yes, read this https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md. This is a convention for naming the files and autoloading classes. You should look the structure of other frameworks like Zend and Symfony too, maybe you will understand.
-
Try to use the preg_replace function: <?php $cleanData = preg_replace('/[^a-zA-Z0-9]/', '', $inputData); ?> It will remove all thats not between A-Z, a-z and 0-9.
-
How can i count the Child Nodes in a XML File using PHP?
PeoMachine replied to HumzaKhan's topic in PHP Coding Help
Try yo use the Count function of SimpleXML. simplexml