Jump to content

Ricky55

Members
  • Content Count

    98
  • Joined

  • Last visited

  • Days Won

    1

Ricky55 last won the day on July 21 2016

Ricky55 had the most liked content!

Community Reputation

2 Neutral

About Ricky55

  • Rank
    Regular Member

Contact Methods

  • Website URL
    http://www.qwerty-design.co.uk/

Profile Information

  • Gender
    Male
  • Location
    Yorkshire UK
  1. 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']!='127.0.0.1') { $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
  2. 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());
  3. 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
  4. Thank you!!!!! really appreciate that.
  5. 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>';
  6. 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; } ?>
  7. 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!
  8. 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'; } ?>
  9. 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?
  10. 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; ?>
  11. where else can it be configured? I was changing it in Plesk in the PHP settings.
  12. 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.
  13. Guys just going back to the version, which would you recommend 5.5 or 5.6? A lot of my websites are wordpress if that has any bearing?
  14. oh I didn't realise it was an issue. I thought it sounded recent 5.3 to 5.4. Its my server actually so i better get that sorted. That worked by the way guys thanks very much. I just want to say that I find this the best forum I have use / used. You are all sound guys and are super quick and super helpful. Brilliant! Thanks Richard
×
×
  • 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.