Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Ricky55 last won the day on July 21 2016

Ricky55 had the most liked content!

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Yorkshire UK

Ricky55's Achievements

Regular Member

Regular Member (3/5)



  1. Thanks man. He's now saying this can be done in the Apache config using two ports. Getting a bit out of my depth to be honest.
  2. Hi guys, I have hired a developer to help me create an e-commerce project using Laravel. The customer admin and checkout were written by an in house dev that has since left who wrote these outside of Laravel, using Laravel for just the main admin to control orders etc. I told the new dev to throw away anything that didn’t make good sense or fit with modern best practices. He kept the two sections outside of Laravel, although he is using Laravel for authorisation. Looking at his code I have lost all confidence, I’m no expert but he has functions all over the place, repeated in different files there’s no OOP it looks a mess then yesterday he announced that I’d need two instances of php running on my server to get the site to even work. Not two different versions, the same version. I’ve never even heard of this. He said one for Laravel and one for the other parts of the site. Long story I know but what do you guys think? Is this possible? Is it a bad idea? What do you think of what I’ve said? I’ve googled around and it seems possible to run two different versions of php but that’s not what he’s talking about. Any advice very welcome and sorry if I’ve posted in wrong category. Thanks Richard
  3. Hi guys PHP beginner. I have just moved my site to a new server, the old server had an older version of PHP, 5. something and the new server has version 7. I have a script that powers this page https://www.jaybe.com/guarantee-register/ It just sends an email back to the user and also posts the form contents to a mysql database. A developer that I used to work with set this up for me a long time back. Now when I run the script I get this error Fatal error: Uncaught Error: Call to undefined function ereg() in /var/www/jaybe.com/public_html/_/scripts/guarantee.php:37 Stack trace: #0 {main} thrown in /var/www/jaybe.com/public_html/_/scripts/guarantee.php on line 37 The code from the script is here:- <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $after = "/guarantee-register/thanks.php"; $oops = "/guarantee-register/error.php"; if (isset($_POST['submit']) || isset($_POST['submit_x']) || $_SERVER['REQUEST_METHOD'] == "POST") { $exploits = "/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i"; $profanity = "/(test)/i"; $spamwords = "/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i"; $bots = "/(Indy|Blaiz|Java|libwww-perl|Python|OutfoxBot|User-Agent|PycURL|AlphaServer)/i"; if (preg_match($bots, $_SERVER['HTTP_USER_AGENT'])) { exit("<p>Known spam bots are not allowed.</p>"); } foreach ($_POST as $key => $value) { $value = trim($value); if (empty($value)) { if ($key != "email") { exit("<p>Please go back and complete the required fields.</p>"); } } elseif (preg_match($exploits, $value)) { exit("<p>Exploits/malicious scripting attributes aren't allowed.</p>"); } elseif (preg_match($profanity, $value) || preg_match($spamwords, $value)) { exit("<p>Please keep things clean, no naughty words!</p>"); } $_POST[$key] = stripslashes(strip_tags($value)); } if (!ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,6})$",strtolower($_POST['email']))) { exit("<p>How can we reply if you don't provide us with a valid email address?</p>"); } conn(); $sql = "INSERT INTO guarantee_reg (`gender`, `forename`, `surname`, `address`, `postcode`, `email`, `product`, `date_purchased`, `retailer`, `opt_in`) VALUES ( '" . mysql_real_escape_string($_POST['gender']) . "', '" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['surname']) . "', '" . mysql_real_escape_string($_POST['address']) . "', '" . mysql_real_escape_string($_POST['postcode']) . "', '" . mysql_real_escape_string($_POST['email']) . "', '" . mysql_real_escape_string($_POST['product']) . "', '" . mysql_real_escape_string($_POST['date']) . "', '" . mysql_real_escape_string($_POST['retailer']) . "', '" . mysql_real_escape_string($_POST['opt-in']) . "')"; qry($sql); $recipient = "{$_POST['email']}"; $subject = "Your Jay-Be Guarantee Confirmation"; $message .= "Dear {$_POST['name']}, \n\n Thank you for completing the Jay-Be guarantee registration form. This email is your guarantee registration confirmation, you may wish to print it out for future reference.\n\n"; $year = date('y'); $month = date('m'); $message = ""; $message .= 'Reference number: JB' . $year . $month . "\n\n"; $message .= "The details you provided are as follows: \n\n"; $message .= "Title: {$_POST['title']} \n\n"; $message .= "First Name: {$_POST['name']} \n\n"; $message .= "Surname: {$_POST['surname']} \n\n"; $message .= "Address:\n{$_POST['address']} \n\n"; $message .= "Postcode: {$_POST['postcode']} \n\n"; $message .= "Email: {$_POST['email']} \n\n"; $message .= "Product purchased: {$_POST['product']} \n\n"; $message .= "Date purchased: {$_POST['date']} \n\n"; $message .= "Retailer purchased from: {$_POST['retailer']} \n\n"; $message .= "Added to our marketing database (no if not specified): {$_POST['opt-in']} \n\n"; $headers .= "From: {$_POST['email']}"; if (mail($recipient,$subject,$message,$headers)) { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$after\">"; } else { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$oops\">"; } } function conn() { $host='localhost'; if($_SERVER['SERVER_ADDR']!='') { $user='user'; $pwd='xxx'; $db='fff'; } else { $user='root!'; $pass=''; $db='fff'; } $conn = mysql_connect($host, $user, $pwd) or die ("<h1>mysql_connect Error</h1>\n <ul>\n <li>Error in: " . $_SERVER['PHP_SELF'] . "</li>\n <li>Selecting database : $db</li>\n <li>With username: $user</li>\n <li>And Password: $pass</li>\n <li>mysql_error: " . mysql_error() . "</li>\n </ul>\n"); mysql_select_db($db, $conn) or die("<h1>mysql_select_db Error</h1>\n <ul>\n <li>Error in: " . $_SERVER['PHP_SELF'] . "</li>\n <li>Selecting database : $db</li>\n <li>With username: $user</li>\n <li>And Password: $pass</li>\n <li>mysql_error: " . mysql_error() . "</li>\n </ul>\n"); return $conn; } function qry($sql) { $res = mysql_query($sql) or die("<h1>Error Querying Database</h1>\n<ul><li>SQL: $sql</li>\n<li>Error: " . mysql_error() . "</li>\n</ul>"); return $res; } function qry_row($sql) { $res = qry($sql); $row = mysql_fetch_assoc($res); return $row; } ?> If anyone can shed any light I'd be very grateful. Thanks Richard
  4. I've just found this code. How would I echo this out into my html? function retailerGet($name=null){ $retailers = array('amazon'=>array('href'=>'http://www.amazon.co.uk/', 'src'=>'amazon.png', 'alt'=>'Amazon'), 'argos'=>array('href'=>'http://www.argos.co.uk/', 'src'=>'argos.png', 'alt'=>'Argos'), 'asda'=>array('href'=>'http://www.asda.co.uk/', 'src'=>'asda.png', 'alt'=>'ASDA')); if($name==null){ $keys = array_keys($retailers); shuffle($keys); return $retailers[$keys[mt_rand(0,count($retailers)-1)]]; }else{ return $names[$name]; } } print_r(retailerGet());
  5. Hi guys I have a series of images that are wrapped with links. I need these to display in a random order with each page refresh. I've had a quick look for some code that I can customise but I'm drawing a blank. I just have <a href="http://www.diy.com"><img src="/_/images/where-to-buy/b-and-q.png" alt="B&Q"></a> Obviously I need to keep the href image source and alt tag together. Is there a way to create an array or switch statement and then output it as needed? Thanks guys
  6. Thank you!!!!! really appreciate that.
  7. Hi guys How would I replace the hyphen in between the date and time with the word at ? I've tried a few things but its not working. Thanks Richard ​echo '<div class="gdlr-result-date">' . date_i18n('l dS - H:ia', $match_date) . '</div>';
  8. Hi guys sorry for being a total noob but when I type this code I'm getting an error. Should this be wrapped in a if ? <?php $selector = (isset($_GET['selector']) ? isset($_GET['selector'] : false; switch($selector) { case 'supreme': $href = '/folding-beds/browse-by/supreme'; $text = 'Supreme Collection'; break; case 'deluxe': $href = '/folding-beds/browse-by/deluxe'; $text = 'Deluxe Collection'; break; case 'airflow': default: $href = '/folding-beds/browse-by/airflow'; $text = 'Beds with Airflow Fibre Mattresses'; break; } ?>
  9. As per usual you guys didn't let me down, best forum on the web is this IMO and I'm not just saying that. You can keep your Stack Overflow with their over restrictive rules. Thanks so much guys I really mean that. I do help people with stuff I know, I'm not just one of these lazy sods. I think I'll use Pyscho's suggestion. Mac_gyver yours looks cool but I don't fully understand it :-) Once again thanks!!!! Ps There are 10 options thats why I asked!
  10. Hi guys I only use PHP every now and again so my knowledge is basic at best. I have this code which is working. I was just wondering if there was a better way of writing this. <?php if(isset($_GET['selector'])) { $selector = $_GET['selector']; } if ($selector == 'airflow') { $href = '/folding-beds/browse-by/airflow'; $text = 'Beds with Airflow Fibre Mattresses'; } if ($selector == 'supreme') { $href = '/folding-beds/browse-by/supreme'; $text = 'Supreme Collection'; } if ($selector == '') { $href = '/folding-beds/browse-by/airflow'; $text = 'Beds with Airflow Fibre Mattresses'; } ?>
  11. Thanks for the reply. I didn't think it was actually specific to the plugin. It's more related to just php than it is to the plugin. Surely all info is in my post to provide an answer?
  12. Hi guys I'm using WordPress and the advanced Custom Fields plugin. I have a basic loop that spits out the code for a slider. I'm using the image caption to populate the href of the link. Currently only the first image carries a caption and therefore a link. I need to set my code up so it uses the link when the caption exists and without the link when it doesn't. The advanced custom fields plugin does have a "if field exists" but I just don't know how to write the code. Posted below is my code. <?php $the_query = new WP_Query(array( 'post_type' => 'slider', 'posts_per_page' => '1', )); while ($the_query->have_posts()) : $the_query->the_post(); ?> <?php $images = get_field('image_gallery'); if($images) : ?> <!-- Flex Slider --> <div class="flexslider entry-thumbnail"> <ul class="slides"> <?php foreach ($images as $image) : ?> <li><a href="<?php echo $image['caption']; ?>" data-lity><img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>"></a></li> <?php endforeach; ?> </ul> </div> <?php endif; endwhile; ?> This is the basic example the advanced custom fields plugin gives you to use the if field exists. <?php if( get_field('field_name') ): ?> <p>My field value: <?php the_field('field_name'); ?></p> <?php endif; ?>
  13. where else can it be configured? I was changing it in Plesk in the PHP settings.
  14. Hi guys Bit of a PHP noob and the dev I use is away on holiday and I've got a client screaming at me, the usual carry on :-( I'm getting the following error Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 32 bytes) in /var/www/vhosts/XXXXX.co.uk/httpdocs/os/system/database/drivers/mysql/mysql_result.php on line 167 The memory allocation was set to the default option of 128M I've tried increasing this to 2048M and it still errors. Php Info is reporting the new allocation too. Do I need to set this in the script? or restart the server? any tips would be massively appreciated. I think the app was created using Codeigniter, it uses the MVC framework anyway I know that much. (not sure if that has any bearing) Cheers guys.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.