PHP - Moz Showing Duplicate Content Issues With My Code
http://www.compareandchoose.com.au/video_games?shopingfor=US&shopingfor=US http://www.compareandchoose.com.au/video_games?shopingfor=AU&shopingfor=US http://www.compareandchoose.com.au/video_games?shopingfor=UK&shopingfor=US http://www.compareandchoose.com.au/video_games?shopingfor=US&shopingfor=UK http://www.compareandchoose.com.au/video_games?shopingfor=AU&shopingfor=UK http://www.compareandchoose.com.au/video_games?shopingfor=UK&shopingfor=UK http://www.compareandchoose.com.au/video_games?shopingfor=US&shopingfor=AU http://www.compareandchoose.com.au/video_games?shopingfor=AU&shopingfor=AU http://www.compareandchoose.com.au/video_games?shopingfor=UK&shopingfor=AU when it should only show http://www.compareandchoose.com.au/video_games?shopingfor=US http://www.compareandchoose.com.au/video_games?shopingfor=AU http://www.compareandchoose.com.au/video_games?shopingfor=UK why its appending all combinations I am not sure Please find my 3 page code files it usesHi Professionals I have been doing a site check with MOZ tools and it is showing duplicate page content for all my shopping pages Basically I have a site where you can compare products for either the UK,US or AU But it is showing the above results in MOZ I have tried everything to figure this out, but because it was not written by me I cannot pin point it Please find attached the 3 pages it utilises Attached Files check_form.php 433bytes 5 downloads shopping_video_games.php 3.17KB 6 downloads video_games.php 3.2KB 5 downloads Similar TutorialsHi, I am hoping I have posted my current problem in the right part of this forum. As it relates to the php code, I presume this is the right place, although it also relates to a mysql database I have too. Ok, here is my problem.... I have two websites, one is a non members site and one is a paid members area site. I had a directory style script made for the non members site and want to use the same script within the members site. I paid for the script to be made and set up, which cost me quite a bit, hence the reason I am copying it all over to my other site too. The script displays thumbnials from the database, 4 across and 3 down (total of 12 thumbs per page), each linking to a URL and each thumb has a title. On the left of the webpage is categories, which when clicked, shows thumbs relating to that specific category, or all etc. The CMS forms allow us to add categories etc. Ok, now my problem is this.. I backed up the original database and created a new database on the members site where I also want this functionality. I copied all the scripts over then chenged the content of the database. On the members site I only want it to display three categories, All, Photos and Videos. So this is quite simple compared to the first site. All seemed to display fine, until I moved all the scripts into the members folder (which is accessed via ccbill). The page displays ok, but it just states "No updates found" as in, no content in the database is found. The base url in the configuration script is set to the top domain, but I have renamed the folders where the thumbs are saved to members/thumbs, but still it isnt working. I also want to change the folder name from its original name of www.domain.com/sites to the new domain.com/updates but nothing works when I try to change it. If anyone can help me out with this, I would be extremely grateful, as the workings of this script are all there, and it seems pointless having to spend hundreds on a new script to be made when the functionality is already there, but just not working right. Thanks so much! hey guys, I'm getting a problem uploading my csv file to mysql database, the code on the top half just makes sure that I don't import data that I don't want into the database, numbers that are too high or too low on certain rows, and the second half is importing the array that I create from the csv file into the database however I'm getting the following error
Duplicate entry 'Array' for key 'strProductCode'
Now I've never had this error before and I'm not sure what's causing it so any help would be very much appreciated
$data = array(); if (($handle = fopen("stock.csv", "r")) !== FALSE) { while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) { // only add rows to the array where the 4th column value is greater than or equal to 10 if(($row[3] >= 10 && $row[4] >= 5) OR ($row[3] >= 0 AND $row[4] > 5)){ if($row[4] < 1000){ $data[] = $row; } } } foreach ($data as &$value) { mysql_query("INSERT INTO tblProductData (intProductDataId, strProductCode, strProductName, strProductDesc, strProductStock, strProductCost, dtmDiscontinued, dtmAdded, stmTimestamp) VALUES(null, '$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', 'time', 'added', 'time') ") or die(mysql_error()); } } Hi. I'm new to PHP and Wordpress, quite the beginner. I thought I finally had it all done on my site and I've stumbled on another issue. Basically I post a link and it spits it out. I sometimes post links that have the same domain ($content['host']) but I don't want these to be duplicated. Here's what I have: Code: [Select] <?php query_posts(''); ?> <?php while (have_posts()) : the_post(); ?> <li> <a href="http://<?php $content = parse_url(strip_tags(get_the_content())); echo $content['host']; ?>"> <?php $content = parse_url(strip_tags(get_the_content())); echo $content['host']; ?></a> </li> <?php endwhile;?> I've Googled around for a while, reading posts about how to prevent duplicate posts in multiple loops but can't adapt it to mine. I'd really appreciate any advice. Cheers, Craig. I have created an input field on a website for people to subscribe by their email address. The email address is stored in a database. I am using PHPMyAdmin. The email address is successfully working, but I want to prevent duplicate email address to be stored, however, I am having an error. Here are my codes: HTML codes: Code: [Select] <form action="index.php" method="post"> <input type="text" size="25" placeholder="Your email address..." name="enter"/> <input class="submit" type="submit" value="Subscribe" name="subscribe"/> <br/> PHP with Query codes: Code: [Select] <?php if ( $_SERVER['REQUEST_METHOD'] == "POST" ) { $ee = htmlentities($_POST['enter']); if (!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$ee) || empty($ee)){ echo '<p class="fail">Failed...Try again!</p>'; } else { @mysql_connect ('localhost', 'root', '') or die ('A problem has occurred, refresh the page and try again!'); @mysql_select_db ('links') or die ('A problem has occurred, refresh the page and try again!'); $duplicate = "SELECT * FROM `email` WHERE `emailaadress` = '{$ee}'"; $query = "INSERT INTO email (id, emailaddress) VALUES('NULL', '.$ee')"; $result = mysql_query($duplicate); if ( mysql_num_rows ( $result ) > 1) { /* Username already exists */ echo 'Username already exists'; } else { mysql_query($query); echo '<p class="success">Successfully subscribed!</p>'; } } } ?> Error I am having: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\softwareportfolio\index.php on line 68 Can someone help me? Thank I am having a big problem in MySQL and a part in my PHP coding as well. I created a registration form, where the user will have to fill his names, email address, choose a username and so on. I do not want duplicate email address and username in my database, thus, if a user choose either an email address or a username which has already taken, he will be notified. To prevent this duplication, I have set both the email address and username fields as UNIQUE KEY in MySQL. My problems a Even by setting both the username and email address fields as UNIQUE KEY, it is not working as I can register using the same email address or username. How to solve this? I have coded also to prevent this problem of duplicate so that the user will be notified to choose another email or username, but I am having a warning. My PHP codes: Code: [Select] <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['fname']) && isset($_POST['lname'])&& isset($_POST['emailr']) && isset($_POST['user']) && isset($_POST['pass'])) { //Assignng variables $firstname = mysql_real_escape_string($_POST['fname']); $lastname = mysql_real_escape_string($_POST['lname']); $email = mysql_real_escape_string($_POST['emailr']); $uname = mysql_real_escape_string($_POST['user']); $pwd = mysql_real_escape_string($_POST['pass']); $pmd= md5($pwd); //Database $connect = mysql_connect('localhost', 'root', '') or die ('Connection Failed'); mysql_select_db('registration', $connect) or die ('Connection Failed'); //Registration codes if (empty($firstname) || empty($lastname) || empty($email) || empty($uname) || empty($pmd)) { echo '<p class="error">All fields are required to fill!</p>'; return false; } elseif (strlen($firstname) && (strlen($lastname) < '2')) { echo '<p class="error">Invalid first name or last name!</p>'; return false; } elseif (filter_var($firstname, FILTER_VALIDATE_INT) || (filter_var($lastname, FILTER_VALIDATE_INT))) { echo '<p class="error">First name or last name cannot be integers!</p>'; return false; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '<p class="error">Email address not valid!</p>'; return false; } elseif (strlen($uname) && (strlen($pmd) < '6' )) { echo '<p class="error">Username or password must be minimum 6 characters!</p>'; return false; } else { $query = "INSERT INTO login (id, firstname, lastname, emailaddress, username, password) VALUES('', '$firstname', '$lastname', '$email', '$uname', '$pmd')"; mysql_query($query, $connect); if (mysql_num_rows(mysql_query("SELECT * FROM login WHERE emailaddress = '$email' username = '$uname'"))) { echo '<p class="fail">This email or username is already taken!</p>'; } } } } ?> The warning message I am getting: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\miniimagehosting\register.php on line 44 I have a sorting functionality, the code is he <?php $select_category = $_REQUEST['sort_category']; $sort_date_var = $_REQUEST['sort_date']; $sort_submit = $_POST['sortSubmit']; // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (($select_category == 'All') || (!isset($select_category)) && (!isset($sort_date_var))) { // Retrieve the chosen category from MySQL $query = "SELECT * FROM con"; $data = mysqli_query($dbc, $query); //Loop through the array of data while ($row = mysqli_fetch_array($data)) { echo "<table class='knuffixTable'>"; // Display the score data echo "<tr><td class='knuffix_name'>"; echo "<strong>" . htmlentities($row['name']) . "</strong><br /></td></tr>"; echo "<tr><td class='knuffix_contribution'><pre>" . $row['contribution'] . "</pre><br /></td></tr>"; echo "<tr><td class='knuffix_categoryDate'>" . $row['category'] . " | " . date('M d, Y', strtotime($row['contributed_date'])) . " </td></tr>"; echo "</table>"; } mysqli_close($dbc); } elseif (isset($select_category) && !isset($sort_date_var)) { // Retrieve the chosen category from MySQL $query = "SELECT * FROM con WHERE category = '$select_category'"; $data = mysqli_query($dbc, $query) or die (mysqli_error($dbc)); //Loop through the array of data while ($row = mysqli_fetch_array($data)) { echo "<table class='knuffixTable'>"; // Display the score data echo "<tr><td class='knuffix_name'>"; echo "<strong>" . htmlentities($row['name']) . "</strong><br /></td></tr>"; echo "<tr><td class='knuffix_contribution'><pre>" . $row['contribution'] . "</pre><br /></td></tr>"; echo "<tr><td class='knuffix_categoryDate'>" . htmlentities($row['category']) . " | " . date('M d, Y', strtotime($row['contributed_date'])) . " </td></tr>"; echo "</table>"; } mysqli_close($dbc); } elseif (!isset($select_category) && isset($sort_date_var)) { // Retrieve the chosen category from MySQL $query = "SELECT * FROM con ORDER BY contributed_date $sort_date_var"; $data = mysqli_query($dbc, $query) or die (mysqli_error($dbc)); //Loop through the array of data while ($row = mysqli_fetch_array($data)) { echo "<table class='knuffixTable'>"; // Display the score data echo "<tr><td class='knuffix_name'>"; echo "<strong>" . htmlentities($row['name']) . "</strong><br /></td></tr>"; echo "<tr><td class='knuffix_contribution'><pre>" . $row['contribution'] . "</pre><br /></td></tr>"; echo "<tr><td class='knuffix_categoryDate'>" . htmlentities($row['category']) . " | " . date('M d, Y', strtotime($row['contributed_date'])) . " </td></tr>"; echo "</table>"; } mysqli_close($dbc); } elseif (isset($select_category) && isset($sort_date_var)) { // Retrieve the chosen category from MySQL $query = "SELECT * FROM con WHERE category = '$select_category' ORDER BY contributed_date $sort_date_var"; $data = mysqli_query($dbc, $query) or die (mysqli_error($dbc)); //Loop through the array of data while ($row = mysqli_fetch_array($data)) { echo "<table class='knuffixTable'>"; // Display the score data echo "<tr><td class='knuffix_name'>"; echo "<strong>" . htmlentities($row['name']) . "</strong><br /></td></tr>"; echo "<tr><td class='knuffix_contribution'><pre>" . $row['contribution'] . "</pre><br /></td></tr>"; echo "<tr><td class='knuffix_categoryDate'>" . htmlentities($row['category']) . " | " . date('M d, Y', strtotime($row['contributed_date'])) . " </td></tr>"; echo "</table>"; } mysqli_close($dbc); } ?> With this code I'm able to: - showcase every category by DEFAULT when someone comes to the page. - sort only by category, - sort only by date, - sort by category AND date, The problem is as you can see I have a lot of duplicate code, if I for example want to change the table that is being printed out, I have to change it on all of them. I'd like to ask how I could avoid this duplicate code. Can I for example just have the table ONE TIME at a separate place and then insert the REFERENCE _after_ the query in each if statement? Like this: if (($select_category == 'All') || (!isset($select_category)) && (!isset($sort_date_var))) { // Retrieve the chosen category from MySQL $query = "SELECT * FROM con"; $data = mysqli_query($dbc, $query); table_here(); } elseif (isset($select_category) && !isset($sort_date_var)) { // Retrieve the chosen category from MySQL $query = "SELECT * FROM con WHERE category = '$select_category'"; $data = mysqli_query($dbc, $query) or die (mysqli_error($dbc)); table_here(); } I'm just coding since 2 month so I don't know how do it, maybe I can do it with functions? I've tried doing it with functions, but I got an error since the function doesn't contain any query statement and only the table because it was trying to fetch. it looked like this: function table_here () { //Loop through the array of data while ($row = mysqli_fetch_array($data)) { echo "<table class='knuffixTable'>"; // Display the score data echo "<tr><td class='knuffix_name'>"; echo "<strong>" . htmlentities($row['name']) . "</strong><br /></td></tr>"; echo "<tr><td class='knuffix_contribution'><pre>" . $row['contribution'] . "</pre><br /></td></tr>"; echo "<tr><td class='knuffix_categoryDate'>" . $row['category'] . " | " . date('M d, Y', strtotime($row['contributed_date'])) . " </td></tr>"; echo "</table>"; } mysqli_close($dbc); } hello .. I have 3 tables: student - infractions - Actions and view1 it Includes all tables and i make view1 source my page. my database structu Table: student Columns: ID_student int(11) AI PK name varchar(45) Age varchar(45) Grade varchar(45) Table: infractions Columns: ID_infractions int(11) AI PK infractions_text varchar(45) ID_student int(11) Table: actions Columns: ID_Actions int(11) AI PK Actions_text varchar(45) ID_student int(11) view1 SELECT student.ID_student AS ID_student, student.name AS name, student.Age AS Age, student.Grade AS Grade, infractions.ID_infractions AS ID_infractions, infractions.infractions_text AS infractions_text, actions.ID_Actions AS ID_Actions, actions.Actions_text AS Actions_text FROM (student JOIN infractions ON student.ID_student = infractions.ID_student) JOIN actions ON student.ID_student = actions.ID_student php page code: PHP Code: Hi all, I have table, named: tb_event (id, f_date, f_title, f_image, f_status) How to manage, while if 'f_status' from all records NOT EQUAL to 'Published' then show ABCDE Note: on tb_event should be only the latest record (1 record only) that will be shown/published I have code: <? $qry = mysql_query( "SELECT * FROM tb_event WHERE f_status = 'Published'") or die(mysql_error()); while($res = mysql_fetch_array($qry)) { if ($res[f_status] = "Published") { echo ' <img src="images/uploads/'.$res[f_image].'" border="0" /> '; } else { echo ' ABCDE '; } } ?> The result is 'ABCDE' not shown while f_image (all records) is OFF Please help me.. thanks So i have a basic form that does a pure and simple data entry via MySQL / PHP. However the content being passed through the form is being pasted in from random sources such as PDF, Word Doc, etc... Here's an issue im noticing and do not know how to fix. If someone pastes a paragraph that has a single quote in it, that single quote >> ' << will be replaced in the database with something like so >> ’ << so a word like world's will turn into world’s. Does anyone know if there's a way to fix this issue? Thanks! hello team, can you please look at this code snippet and tell me why it is showing the following data this way? <?php # jeff Exp $ include("app.php"); $page->set("title", "Business & Commerical"); $what = $page->getvar("what"); $type = $page->getvar("type"); $dt = new xDataTable('width="500"'); $form = new Form(); if($what == "submit") $html->set("readonly", true); $dt->header($_types{$type} . " Quote"); $form->get_contact_form(true); When I run it, it shows like this: set("title", "Business & Commerical"); $what = $page->getvar("what"); $type = $page->getvar("type"); $dt = new xDataTable('width="500"'); $form = new Form(); if($what == "submit") $html->set("readonly", true); $dt->header($_types{$type} . " Quote"); $form->get_contact_form(true); switch ($type) { case "comp": $dt->left("Business Type:"); $dt->cell($html->select("business_type", $_business_type, 1, "", $page->getvar("business_type"), "(select)")); $dt->left("Federal Tax ID:"); $dt->cell($html->textfield("tax_id", $page->getvar("tax_id"), 12)); $dt->left("If Individual, Owner SSN#:"); $dt->cell($html->textfield("ssn", $page->getvar("ssn"), 12)); $dt->cell("Spouse SSN#:"); $dt->cell($html->textfield("spouse_ssn", $page->getvar("spouse_ssn"), 12)); just a small sample. What am I doing wrong? Thanks alot in advance This is the script i am using i two areas , but the goal is not the same :( Code: <div class='allDeal'> <div class='date'><?php echo app()->locale->dateFormatter->formatDateTime( utime($data->start,false),'medium',false); ?></div> <div class='content'> <div class='name'><?php echo CHtml::link($data->name,url('/deal/view',array('url'=>$data->url))); ?></div> <div class='clearfix prepend-top'> <div class='column data'> <div class='stats txt-center'> <span class='num'><?php echo $data->stats && $data->stats->bought?$data->stats->bought:'0'; ?></span><br /> <?php echo $this->t('Coupons Bought'); ?> </div> <div class='info prepend-top'> <div class='row price'> <label><?php echo $this->t('Price').':'; ?></label> <?php echo m('payment')->format($data->price); ?> </div> <div class='row'> <label><?php echo $this->t('Value').':'; ?></label> <?php echo m('payment')->format($data->value); ?> </div> <div class='row'> <label><?php echo $this->t('Savings').':'; ?></label> <?php echo m('payment')->format($data->value-$data->price); ?> </div> </div> </div> <div class='column last image'><?php if($data->imageBin) echo CHtml::link( CHtml::image(app()->storage->bin($data->imageBin)->getFileUrl('original')), url('/deal/view',array('url'=>$data->url)) ); ?></div> </div> </div> </div><?php if($index && ($index+1)%2==0) { ?><div class='clearfix'></div><?php } Only change: div class='allDeal' to div class='recentDeal' This is the good: http://kupon.woano.lv/deal/recent and the same code in other place looks ugly :( http://kupon.woano.lv/deal/all What i am doing wrong This is the code that I am using to make a page that is kind of like an administration area for a CMS system. When the page is loading all I get is a blank page. When I remove all of the back code before the HTML code is sent. The page shows up fine. I have looked over and over the code trying to see if I missed a colon or something and I see nothing. I hope that this explains everything well enough and I would appreciate any help. Code: [Select] <?php $today = date("l, F j, Y"); $host =''; $username = ''; $dbname =''; $dbpassword = ''; $table = ''; $table2 = ''; $connection = mysql_connect($host, $username, $dbpassword) or die (mysql_error()); $db = mysql_select_db ($dbname, $connection) or die (mysql_error()); $sql = "SELECT * FROM $table WHERE username = '$_POST[username]' AND password = password('$_POST[password]')"; $result = mysql_query($sql, $connection) or die(mysql_error()); $num = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $f_name = $row['f_name']; $l_name = $row['l_name']; $username = $row['username']; } if ($num != 0) { $_SESSION[auth] = "yes"; $msg = "Welcome $f_name "; } //else { //header("Location: index.php"); //exit; //} $get_count = "SELECT count(id) FROM $table2"; $get_count_res = mysql_query($get_count, $connection) or die (mysql_error()); $count = mysql_result($get_count_res, 0, "count(id)") or die (mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/reset.css" media="screen" /> <link rel="stylesheet" type="text/css" href="css/admin.css" media="screen" /> <title>Administration Area</title> </head> <body> <div id="wrapper"> <?php include('includes/header.php'); ?> <div id="content"> <div class="message"><?php echo "$msg"; ?> <a href="logout.php">Logout</a><span style="float:right; "><?php echo "$today"; ?></span></div> <div class="admin"> <span class="top">Administration</span> <ul> <li><A href="show_add.php">Add a Ad</A></li> <li><a href="pick_modify.php">Modify a Add</a></li> <li>Delete Ad</li> <li><a href="user/index.php">Add a User</a></li> <li><a href="user/pick_user.php">Delete a User</a></li> <li><a href="#">View Database Records</a></li> <li><a href="php_info.php">PHP info</a></li> <li><a href="make_backup.php">Backup Database</a> </li> <li><a href="https://p3nlmysqladm001.secureserver.net/nl50/529/index.php?lang=en-utf-8&token=db052d2ddafce3f6ba841cfe0a6c224a">View Database</a> </li> </ul> </div> <div class="misc"><span class="top">miscellaneous</span>Classified Ads online <?php echo "$count"; ?></div> </div> <!--End #content--> <?php include('includes/footer.php'); ?> </div> <!-- End #wrapper --> </body> </html> Hi , I have one question .. Can I split showing of content of dynamic list in 2 parts , when I echo list in code .. Code: [Select] <?php // Run a select query to get my letest 8 items // Connect to the MySQL database include "../connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 8"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= '<table width="100%" border="2" cellspacing="2" cellpadding="2"> <tr> <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="2" /></a></td> <td width="83%" valign="top">' . $product_name . '<br /> $' . $price . '<br /> <a href="product.php?id=' . $id . '">View Product Details</a></td> </tr> </table>'; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> Code: [Select] <p><?php echo $dynamicList; ?><br /> </p> It works ok, and putting my files, everything works, but when I put 8 pictures with price and other details, it just show one image with details and another image below with details, and the third image below and so on .. Can I split dynamic list to show 4 images with details on the left side and 4 on the right side? Thank you in advance for help , if is possible This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=330251.0 Hi, first of all I am trying to do a section hidden from guests on a website. I have groups for each user (groups_admin, _mod, _member etc.)
I have it so ADMIN only view content at the moment, but not sure how to add GROUPS_MOD & GROUPS_MEMBER:
<?php echo $user_data['group_id'] == GROUPS_ADMIN ? 'content' : ''; ?>Secondly, where the content section is, I have HTML placed inside it which works fine, but it also has some PHP code. How would I get it so the php code works? This is what I have... <?php echo $user_data['group_id'] == GROUPS_ADMIN ? '<form method="post" action="<?php echo get_url(\'/products/\', $product[\'category_id\'], $product[\'product_id\'], $product[\'product_name\']); ?>?action=review">' : ''; ?>As you can see the form action line has a php url to generate the relevant link for a specific product. If anyone has any suggestions or can help in any way that would be much appreictaed. Cheers, Paul I am taking a form that has been created and now trying to incorporate it into WP. The form is filled out multiple times per session. The form when filled out will generate an ID that is used to track the form submissions until completed. The problem that I'm running into is that the code is using a URL structure that breaks on the install.
I'm not sure what to tell the code to look for as the URL.
I hope I'm making sense. This is my first dive into WP dev. Thanks for the help.
<?php /* Template Name: Form */ ?> <?php /** * The template for displaying all pages * * This is the template that displays all pages by default. * Please note that this is the WordPress construct of pages and that * other 'pages' on your WordPress site will use a different template. * * @package WordPress * @subpackage Twenty_Thirteen * @since Twenty Thirteen 1.0 */ get_header(); ?> <div id="main-content" class="main-content"> <div id="headertitle"> <h1>Steam Trap Form Input</h1> </div> <div id="formtable"> <form class="form-horizontal" role="form" action="/test/FormHandler.php" method="post"> <fieldset> <div class="form-group"> <label for="dateSurvey" class="col-sm-2 control-label">Survey Date</label> <div class="col-sm-6"> <input type="text"<? echo (isset($sd['date']) ? ' value="'.format_date($sd['date']).'"' : '') ?> class="form-control col-sm-6 input-append date" id="dp1" name="dateSurvey" data-date="02-12-2014" data-date-format="mm-dd-yyyy"> </div> </div> <div class="form-group"> <label for="plantName" class="col-sm-2 control-label">Plant Name</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="plantName"<? echo (isset($sd['plant_name']) ? ' value="'.$sd['plant_name'].'"' : '') ?>> </div> </div> <div class="form-group"> <label for="plantLoc" class="col-sm-2 control-label">Plant Location</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="plantLoc"<? echo (isset($sd['plant_location']) ? ' value="'.$sd['plant_location'].'"' : '') ?>> </div> </div> <div class="form-group"> <label for="plantContact" class="col-sm-2 control-label">Plant Contact Name</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="plantContact"<? echo (isset($sd['plant_contact_name']) ? ' value="'.$sd['plant_contact_name'].'"' : '') ?>> </div> </div> <div class="form-group"> <label for="pph" class="col-sm-2 control-label">Pound Per Hour</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="pph" placeholder="XX.XX"<? echo (isset($sd['pph']) ? ' value="'.$sd['pph'].'"' : '') ?>> </div> </div> <div class="form-group"> <label for="area" class="col-sm-2 control-label">Area</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="area" placeholder="Boiler Room"<? echo (isset($sd['area']) ? ' value="'.$sd['area'].'"' : '') ?>> </div> </div> <hr> <div class="form-group"> <label for="testDate" class="col-sm-2 control-label">Tested Date</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6 input-append date" id="dp2" name="testDate" data-date="02-12-2014" data-date-format="mm-dd-yyyy"> </div> </div> <!-- <div class="form-group"> <label for="direction" class="col-sm-2 control-label">Direction</label> <div class="col-sm-6"> <select class="form-control col-sm-6" name="direction"> <option value="N">N</option> <option value="NE">NE</option> <option value="NW">NW</option> <option value="S">S</option> <option value="SE">SE</option> <option value="SW">SW</option> <option value="E">E</option> <option value="W">W</option> </select> </div> </div> --> <div class="form-group"> <label for="location" class="col-sm-2 control-label">Location</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="location" placeholder=" 'Detailed as possible'"> </div> </div> <div class="form-group"> <label for="flrLevel" class="col-sm-2 control-label">Floor Level</label> <div class="col-sm-6"> <select class="form-control col-sm-6" name="flrLevel"> <option value="GROUND">Ground</option> <option value="1st">1st</option> <option value="2nd">2nd</option> <option value="3rd">3rd</option> <option value="4th">4th</option> <option value="5th">5th</option> <option value="6th">6th</option> <option value="7th">7th</option> <option value="8th">8th</option> <option value="9th">9th</option> <option value="10th">10th</option> <option value="11th">11th</option> <option value="12th">12th</option> <option value="13th">13th</option> <option value="14th">14th</option> <option value="15th">15th</option> </select> </div> </div> <div class="form-group"> <label for="elevation" class="col-sm-2 control-label">Elevation</label> <div class="col-sm-6"> <input type="number" class="form-control col-sm-6" name="elevation" placeholder="in feet"> </div> </div> <div class="form-group"> <label for="tagNum" class="col-sm-2 control-label">Tag Number</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="tagNum"> </div> </div> <div class="form-group"> <label for="manufacturer" class="col-sm-2 control-label">Manufacturer</label> <? /* <input type="text" name="mmn" size="30"> */ ?> <div class="col-sm-6"> <select name="manufacturer" class="depend col-sm-6 form-control" id="manufacturer"> <option value="" selected="selected" disabled="disabled">Select Manufacturer</option> </select> </div> <div id="status"></div> </div> <div class="form-group"> <label for="model" class="col-sm-2 control-label">Model Number</label> <div class="col-sm-6"> <select name="model" class="depend col-sm-6 form-control" id="model"> <option value="" selected="selected">Select value</option> </select> </div> </div> <div class="form-group"> <label for="size" class="col-sm-2 control-label">Size</label> <div class="col-sm-6"> <select name="size" class="depend col-sm-6 form-control" id="size"> <option value="" selected="selected">Select value</option> </select> </div> </div> <div class="form-group"> <label for="pressure" class="col-sm-2 control-label">Pressure</label> <div class="col-sm-6"> <select name="pressure" id="pressure" class="col-sm-6 form-control"> <option value="" selected="selected">Select value</option> </select> </div> </div> <div class="form-group"> <label for="service" class="col-sm-2 control-label">Service</label> <div class="col-sm-6"> <select class="form-control col-sm-6" name="service" name="service"> <option value="TRACER">TRACER</option> <option value="HEATER">HEATER</option> <option value="PROCESS">PROCESS</option> <option value="DRIP">DRIP</option> </select> </div> </div> <div class="form-group"> <label for="trapCond" class="col-sm-2 control-label">Trap Conditions</label> <div class="col-sm-6"> <select class="form-control col-sm-6" name="trapCond"> <option value="OK">OK</option> <option value="BT">BT</option> <option value="CP">CP</option> <option value="VO">VO</option> <option value="RCL">RCL</option> </select> </div> </div> <p></p> <div class="form-group"> <div class="col-sm-offset-2 col-sm-6"> <? if(isset($surveyID)) { echo '<input type="hidden" name="surveyID" value="'.intval($_GET['survey']).'">'; } ?> <!-- <? if(isset($areaID)) { echo '<input type="hidden" name="areaID" value="'.intval($_GET['area']).'">'; } ?> --> <button class="btn btn-default btn-lg" type="submit" name="submit" value="add">Add Trap</button> <button class="btn btn-primary btn-lg" type="submit" name="submit" value="add_area">Submit Area</button> <button class="btn btn-danger btn-lg" type="submit" name="submit" value="submit">Submit Survey</button> </div> </div> </fieldset> </form> </div> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <!-- <script src="../script/js/script.js"></script> --> <script src="../script/js/live.js"></script> <script src="../script/js/bootstrap-datepicker.js"></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#dp1').datepicker({ dateFormat : 'dd-mm-yy' }); }); jQuery(document).ready(function() { jQuery('#dp2').datepicker({ dateFormat : 'dd-mm-yy' }); }); </script> </body> </html> <!-- #content --> </div><!-- #primary --> <?php get_sidebar( 'content' ); ?> </div><!-- #main-content --> <?php get_sidebar(); get_footer(); ?> <?php require("../test/base.php"); if(isset($_POST['submit'])) { $url = '../test/form'; // path to form.php if(!isset($_POST['manufacturer'])) { $_POST['manufacturer'] = NULL; } if(!isset($_POST['model_number'])) { $_POST['model_number'] = NULL; } if(!isset($_POST['size'])) { $_POST['size'] = NULL; } if(!isset($_POST['pressure'])) { $_POST['pressure'] = NULL; } $data = prep($_POST); if($data['submit'] == 'add') { if(!isset($data['surveyID'])) { $surveyID = save_survey($data); } else { $surveyID = $data['surveyID']; } save_survey_details($surveyID, $data); if($surveyID) { header('Location: '.$url.'?survey='.$surveyID); } } if($data['submit'] == 'add_area') { if(!isset($data['areaID'])) { $areaID = save_survey($data); } else { $areaID = $data['areaID']; } save_survey_details($areaID, $data); if($areaID) { header('Location: '.$url.'?survey='.$areaID); } } elseif($data['submit'] == 'submit') { if(isset($data['surveyID'])) { save_survey_details($data['surveyID'], $data); } else { $surveyID = save_survey($data); save_survey_details($surveyID, $data); } header('Location: '.$url); } } function prep($input) { $data = array(); if(is_array($input)) { foreach ($input as $key => $val) { $data[$key] = mysql_real_escape_string($val); } } return $data; } function format_date($date = '') { if(isset($date) && $date) { $tmp = explode('-', $date); $d = $tmp[2].'-'.$tmp[0].'-'.$tmp[1]; } else { $d = NULL; } return $d; } function save_survey($data) { $result = mysql_query("INSERT INTO surveys (date, plant_name, plant_location, plant_contact_name, pph, area) VALUES('".format_date($data['dateSurvey'])."','".$data['plantName']."','".$data['plantLoc']."','".$data['plantContact']."','".$data['pph']."','".$data['area']."')") or die('Error: ' . mysql_error()); $result = mysql_query("INSERT INTO area (date, plant_name, plant_location, plant_contact_name, pph, area) VALUES('".format_date($data['dateSurvey'])."','".$data['plantName']."','".$data['plantLoc']."','".$data['plantContact']."','".$data['pph']."','".$data['area']."')") or die('Error: ' . mysql_error()); return mysql_insert_id(); } function save_survey_details($surveyID, $data) { $result = mysql_query("INSERT INTO survey_details (survey_id, tested_date, direction, location, floor_level, elevation, tag_number, manufacturer, model_number, size, pressure, service, trap_conditions) VALUES($surveyID, '".format_date($data['testDate'])."','".$data['direction']."','".$data['location']."','".$data['flrLevel']."','".$data['elevation']."','".$data['tagNum']."','".$data['manufacturer']."','".$data['model']."','".$data['size']."','".$data['pressure']."','".$data['service']."','".$data['trapCond']."')"); $result = mysql_query("INSERT INTO area_details (survey_id, tested_date, direction, location, floor_level, elevation, tag_number, manufacturer, model_number, size, pressure, service, trap_conditions) VALUES($surveyID, '".format_date($data['testDate'])."','".$data['direction']."','".$data['location']."','".$data['flrLevel']."','".$data['elevation']."','".$data['tagNum']."','".$data['manufacturer']."','".$data['model']."','".$data['size']."','".$data['pressure']."','".$data['service']."','".$data['trapCond']."')"); //or die('Error: ' . mysql_error()); } ?> Hello, I am learning php in a class for school and I was hoping I could get some help with some code. I am trying to make a game life counter. I just want it to have simple +1, -1 and reset buttons. I have gotten it to add and subtract the first time, but it will not continue adding/subtracting. Thank you for any help you can give. Here is the code I'm having issues with: <?php session_start(); ?> <form method="post" action =""> <input type="submit" name="name" value="Add"/> <input type="submit" name="name" value="Minus"/> <input type="submit" name="name" value="Reset"/> </form> <? lifeTotal(); function lifeTotal() { $_SESSION['total']=20; if($_POST["name"] == 'Add') { $_SESSION['total']++; echo $_SESSION['total']; } else if($_POST["name"] =='Minus') { $_SESSION['total']--; echo $_SESSION['total']; } } ?> Hello, I'm not able to figure how to fix these warnings / errors I'm getting. The file that I'm creating comes out correctly so it's as if I need some type of conditional to end the function calls or something? I'm really stumped with this one... Code: [Select] Undefined index: 1 Invalid argument supplied for foreach() Undefined index: 4 Invalid argument supplied for foreach() Undefined index: 7 Invalid argument supplied for foreach() Undefined index: 21 Invalid argument supplied for foreach() Undefined index: 2 Invalid argument supplied for foreach() Undefined index: 11 Invalid argument supplied for foreach() Undefined index: 6 Invalid argument supplied for foreach() Undefined index: 22 Invalid argument supplied for foreach() Undefined index: 24 Invalid argument supplied for foreach() Here is a var_dump of $menu Code: [Select] array(2) { ["items"]=> array(12) { [1]=> object(stdClass)#17 (10) { ["id"]=> string(1) "1" ["name"]=> string(4) "HOME" ["parent"]=> string(1) "0" ["type"]=> string(9) "slideshow" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [5]=> object(stdClass)#18 (10) { ["id"]=> string(1) "5" ["name"]=> string(4) "INFO" ["parent"]=> string(1) "0" ["type"]=> string(6) "parent" ["order"]=> string(1) "2" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [3]=> object(stdClass)#19 (10) { ["id"]=> string(1) "3" ["name"]=> string(9) "GALLERIES" ["parent"]=> string(1) "0" ["type"]=> string(6) "parent" ["order"]=> string(1) "3" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [18]=> object(stdClass)#20 (10) { ["id"]=> string(2) "18" ["name"]=> string(16) "GALLERY SECTIONS" ["parent"]=> string(1) "0" ["type"]=> string(14) "gallery_portal" ["order"]=> string(1) "4" ["visible"]=> string(4) "true" ["image"]=> string(11) "DSC0250.jpg" ["color"]=> string(6) "848a5a" ["link"]=> NULL ["target"]=> NULL } [22]=> object(stdClass)#21 (10) { ["id"]=> string(2) "22" ["name"]=> string(7) "CONTACT" ["parent"]=> string(1) "0" ["type"]=> string(5) "forms" ["order"]=> string(1) "5" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [24]=> object(stdClass)#22 (10) { ["id"]=> string(2) "24" ["name"]=> string(12) "MAILING LIST" ["parent"]=> string(1) "0" ["type"]=> string(5) "forms" ["order"]=> string(1) "6" ["visible"]=> string(5) "false" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [2]=> object(stdClass)#23 (10) { ["id"]=> string(1) "2" ["name"]=> string(7) "WEDDING" ["parent"]=> string(1) "3" ["type"]=> string(7) "gallery" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [4]=> object(stdClass)#24 (10) { ["id"]=> string(1) "4" ["name"]=> string(8) "ABOUT US" ["parent"]=> string(1) "5" ["type"]=> string(9) "text_page" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [7]=> object(stdClass)#25 (10) { ["id"]=> string(1) "7" ["name"]=> string(8) "CALENDAR" ["parent"]=> string(1) "5" ["type"]=> string(8) "calendar" ["order"]=> string(1) "2" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [21]=> object(stdClass)#26 (10) { ["id"]=> string(2) "21" ["name"]=> string(14) "PORTFOLIOSITEZ" ["parent"]=> string(1) "5" ["type"]=> string(8) "external" ["order"]=> string(1) "3" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> string(25) "http://portfoliositez.com" ["target"]=> string(6) "_blank" } [11]=> object(stdClass)#27 (10) { ["id"]=> string(2) "11" ["name"]=> string(9) "LANDSCAPE" ["parent"]=> string(2) "18" ["type"]=> string(7) "gallery" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [6]=> object(stdClass)#28 (10) { ["id"]=> string(1) "6" ["name"]=> string(9) "PORTRAITS" ["parent"]=> string(2) "18" ["type"]=> string(7) "gallery" ["order"]=> string(1) "2" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } } ["parents"]=> array(4) { [0]=> array(6) { [0]=> string(1) "1" [1]=> string(1) "5" [2]=> string(1) "3" [3]=> string(2) "18" [4]=> string(2) "22" [5]=> string(2) "24" } [3]=> array(1) { [0]=> string(1) "2" } [5]=> array(3) { [0]=> string(1) "4" [1]=> string(1) "7" [2]=> string(2) "21" } [18]=> array(2) { [0]=> string(2) "11" [1]=> string(1) "6" } } } And here is the code Code: [Select] public function sitemap() { $query = $this->db->order_by('parent', 'asc')->order_by('order', 'asc')->get('menu'); foreach($query->result() as $row) { $menu['items'][$row->id] = $row; $menu['parents'][$row->parent][] = $row->id; } function build_map($parent, $menu, &$data) { foreach($menu['parents'][$parent] as $itemId) { if(!isset($menu['parents'][$itemId])) { if(($menu['items'][$itemId]->parent == 0) && ($menu['items'][$itemId]->visible != 'false')) { $name = str_replace(' ','-', $menu['items'][$itemId]->name); $data .= "\t<url><loc>" . base_url() . "#!/". $name ."</loc></url>\n"; } elseif($menu['items'][$itemId]->visible != 'false' && $menu['items'][$itemId]->type !='external' && $menu['items'][$itemId]->type != 'parent') { $name = str_replace(' ','-', $menu['items'][$itemId]->name); $name2 = str_replace(' ','-', $menu['items'][$menu['items'][$itemId]->parent]->name); $data .= "\t<url><loc>" . base_url() . "#!/". $name2 ."/" . $name ."</loc></url>\n"; } } if(isset($menu['parents'][$itemId]) && $menu['items'][$itemId]->visible != 'false' && $menu['items'][$itemId]->type != 'parent' && $menu['items'][$itemId]->type !='external') { $name = str_replace(' ','-', $menu['items'][$itemId]->name); $data .= "\t<url><loc>" . base_url() . "#!/". $name ."</loc></url>\n"; } build_map($itemId, $menu, $data); } } $data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n\t<url><loc>".base_url()."</loc></url>\n"; build_map(0, $menu, $data); $data .= "</urlset>"; write_file('sitemap.xml', $data); } I'm working on a project that has a lot of different timezone options, and all I have from the users is their UTC offset. After weeks of doing tweaks, I come to new issues every time I add something, one would think it would be a lot easier to just get the correct time and day :) The latest issue is that when I try to rewrite a date to a better fomat, it disregards the GMT offset. Like this: 4/14/19, 12:00 PM GMT+2 (=$date) becomes ... 14-04-2019 10:00 when using this code: $bp_date_to_format = date_create_from_format('Y-m-d\TH:i:sP', $date); echo date_format($bp_date_to_format, 'd-m-Y H:i'); I figured it would just rewrite the format, keeping the exact time. It isn't. We do have all these sorts of localization functions as well, but because there doesn't seem to be one single standard (each 3rd party API connection we have uses its own default datetime format so it seems). // Remove UTC Text $UTC_offset = str_replace('UTC', '', $timezone); // Get Offset in Minutes if (stripos($UTC_offset, ':') !== false) { // Calculate seconds from offset list($hours, $minutes) = explode(':', $offset); $seconds = $hours * 60 * 60 + $minutes * 60; } else { $seconds = $UTC_offset * 60 * 60; } // Get User timezone name from seconds $timezone = timezone_name_from_abbr('', $seconds, 1); if ($timezone === false) { $timezone = timezone_name_from_abbr('', $seconds, 0); } // Set new TZ return date_default_timezone_set($timezone);
Isn't there any "one way"solution that can be used? It's confusing to say the least.
Cheers. I want a code to automatically make specific words within my content bold. For example, If the word "car" appears, make that word bold. Thanks |