simplypixie 123 Posting Pro in Training

I am consfused as you say you want to update table 2 from table 1 but your query that isn't working is updating table 1 from table 1. Please clarify which table it is you need to update

simplypixie 123 Posting Pro in Training

JorgeM - the point is that I DO want the links to work and they don't but I have sorted the problem now anyway

simplypixie 123 Posting Pro in Training

Please look at my jsfiddle here - http://jsfiddle.net/ftuZ5/ . I know why the links won't work as the relative positioning I have used to create the link / menu backgrounds I want is covering the a element but I can't work out how to resolve the issue (having tried relative and z-index on the li and a elements, plus adding and extra div to span the a element using that to create the 'button' style background) but all to no avail.

Can anyone help?

simplypixie 123 Posting Pro in Training

I don't mean to sound rude but you really need to find a way to look through your code and find errors for yourself as that is all I am doing for you by closing/minimizing blocks of code or saving to a new file and then putting sections back until you find the one that has the missing closing tag (which causes the error you are getting).

Again, you have a mising endif statement in your code on line 460:

<div><?php if(!empty($item->fields_by_id[14])):?><?php echo $item->fields_by_id[14]->result; ?></div>

Should be:

<div><?php if(!empty($item->fields_by_id[14])):?><?php echo $item->fields_by_id[14]->result; ?><?php endif; ?></div>
simplypixie 123 Posting Pro in Training

In lines 229 and 235 you have forgotten the <?php endif; ?> (added below)

<div id="excerpt">
        <div>
            <p><span id="label"><b>Excerpt:</b></span>
            <div style="float:left;">
                <div><?php if(!empty($item->fields_by_id[32])):?><?php echo $item->fields_by_id[32]->result; ?><?php endif; ?></div>
            </div>
        </div>
    </div>

    <div id="memreview">
        <div><?php if(!empty($item->fields_by_id[14])):?><?php echo $item->fields_by_id[14]->result; ?><?php endif; ?></div>
    </div>

I have also noticed that you have some extra opening and closing tags in lines 145 to 150:

<div class="page-header">
                <<?php echo $params->get('tmpl_params.title_tag', 'h1')?>>
                    <?php echo $item->title?>
                    <?php echo CEventsHelper::showNum('record', $item->id);?>
                </<?php echo $params->get('tmpl_params.title_tag', 'h1')?>>
            </div>
simplypixie 123 Posting Pro in Training

Where is the value of $semesterid being set and why are you repeating the same code twice for your query and dropdown?

simplypixie 123 Posting Pro in Training

Well you will do as you are selecting all records and echoing them out through one loop all in the same unordered list. What exactly are you trying to do?

simplypixie 123 Posting Pro in Training

Sorry but I don't want to download your code and go through it all - I want you to post the relevant sections of code on here

simplypixie 123 Posting Pro in Training

Well it is difficult to answer properly without seeing what you have done so far but I would have a friends table that will hold the ids of users with related ids of their friends and then you can just cross reference that table to match friend ids with user ids stored with your posts

simplypixie 123 Posting Pro in Training

It is your container div causing the problem and it is not required - remove it and the extra space will disappear. This then leaves the problem that if the content is too little the fotter will have a gap underneath it but that can be fixed by using position: absolute instead of position: relative.

If you really want to keep the container div then move your footer inside it as for some reason you have it outside yet you have your header inside.

simplypixie 123 Posting Pro in Training

It should be if (isset($_POST['button1']) && !empty($_POST['text1'])) {

simplypixie 123 Posting Pro in Training

Are you sure $_REQUEST['newstype'] actually has a value?

Is the text of your echo being displayed?

How are you sending through 'newstype' (post or get)?

simplypixie 123 Posting Pro in Training

The code in your page

<?php
  if (isset($_POST['button1'])){
  $name=$_POST['text1'];
  }else{
  $name="";     
  }
  if ($name) {
  echo 'My name is ' . $name;
 }else{
 echo 'No name entered';
 }
 ?>

is different to the code that you have posted below and incorrect to only run the echo if the form has been submitted, change it to the correct code

<?php
    if (isset($_POST['button1']))&& !empty($_POST['text1']){
        $name=$_POST['text'];
    if ($name) {
    echo 'My name is ' . $name;
    }else{
    echo 'No name was Entered';
    }
    }
    ?>

Notice the if else statement above is warpped inside the if stement to check if any data has been posted

simplypixie 123 Posting Pro in Training

You can use += which will add onto each previosu total through a loop

$koinp=mysql_num_rows($coinp);
$total = 0; // Put this is to define the variable and set the initial amount to 0
while($oinp=mysql_fetch_array($coinp)){



$comme=mysql_num_rows($comentar);   
   // echo" ($comme) </br>";
$total += $comme; // Add each value of $comme to the current $total

The outside your loop echo the $total

simplypixie 123 Posting Pro in Training

Yes it is in the page

simplypixie 123 Posting Pro in Training

OK, thank you for your help and for testing for me. I am going to remove all the code and try to run it separately and go from there as it may be that some other js is causing the problem (I don't have it public at the moment). I also thought about the path to the file but I have tried the full path and that doesn't work either.

I will let you know how I get on.

simplypixie 123 Posting Pro in Training

You would need to use a combination of jQuery, Ajax and PHP

simplypixie 123 Posting Pro in Training

Are you looking to create 3 columns in each section?

simplypixie 123 Posting Pro in Training

It looks like (shortened:

[{title:"About",value:"about-united-diesel"},{title:"About Viezu",value:"vehicle-tuning-remapping\/about-viezu"},{title:"Contact",value:"contact-united-diesel"},{title:"Delivery",value:"delivery"}]

As I say I also tried preg_replace to remove the double quotes from the keys but that didn't work either

simplypixie 123 Posting Pro in Training

Thank you but as I have written in line 14 of my php code, I have also tried echo and that didn't work either

simplypixie 123 Posting Pro in Training

I am using tinymce on a cms and I want to be able to have a dropdown menu of all pages on the site (stored in a db) to choose from when adding a link but all I am getting is an emtpy set of values.

I am using the Link plugin and have the following in my tinymce init:

tinymce.init({
            selector: "textarea#description, textarea#answer",
            menubar: false,
            width: '58%',
            height: 200,
            plugins: ["link","paste"],
            paste_as_text: true,
            toolbar: "undo redo | bold | bullist numlist | link unlink",
            link_list: "../inc/internal-links-list.php"
        });

I am not sure if the url for the link list is correct (it is relative to the file that this code is in).

And in my php:

<?php
require_once("core.php");

$objPage = new Pages;
$pages = $objPage->get_all();
$urls = array();

foreach ($pages as $page) {
    $urls[] = array('title' => $page['page'], 'value' => $page['url']);
}

return json_encode($urls);

// Also tried echo json_encode($urls);

// Below is something I have tried to remove the double quotes around the keys to see if that was the problem but no
//$array_final = json_encode($urls);
//$array_final = preg_replace('/"([a-zA-Z_]+[a-zA-Z0-9_]*)":/','$1:',$array_final);
//echo $array_final;

?>

When I inspect the dropdown element I basically see a lot of empty divs, like so:

<div id="mce_137" class="mce-menu-item mce-stack-layout-item" tabindex="-1" role="menuitem"><i class="mce-ico mce-i-none"></i>&nbsp;<span id="mce_137-text" class="mce-text"></span></div>
<i class="mce-ico mce-i-none"></i>
&nbsp;
<span id="mce_137-text" class="mce-text"></span>
</div>

Can anyone shed any light please?

simplypixie 123 Posting Pro in Training

I didn't tell you to use if(file_exists($uploadFilename)) I said use if (!empty($_FILES))

So all you should need to do to allow the form to be submitted without an image is change your if statement if (!is_uploaded_file($_FILES[$fieldname]['tmp_name'])) to if (!empty($_FILES)) and inside the if statement run all your checks on image type, reformatting and resizing etc and just ensure that the rest of the form posted data and your insert / update is outside of this if statement.

Your code could actually be much more simple as well and I was going to post what I use but at the moment I combine it with jquery and ajax so would just confuse you more, however a quick search gave me this page which might help you

simplypixie 123 Posting Pro in Training

Just wrap your code in an if statement and if there is a file it will run the image processing, otherwise it will just ignore it (then load your default image on the front end)

 if (!empty($_FILES)) {

 }

In fact this should replace your current if statement

simplypixie 123 Posting Pro in Training

If it is an existing user then from your first query it would be

$sql = "SELECT * FROM ".$pdo_usertable." WHERE authorname = '".$post_username."' AND authoremail = '".$post_useremail."'";
    $statement = $pdo->prepare($sql);
    $statement->execute();
    $result = $statement->fetchAll(PDO::FETCH_ASSOC);
    $user_id = $result['id'];

If it is a newly inserted user then (as long as the user ids are auto incremented) then you retrieve that last inserted id
return $this->db->lastInsertId();

if (count($result) == 0)
    {
      $sql = "INSERT INTO ".$pdo_usertable." (authorname, authoremail) VALUES ('$post_username', '$post_useremail')";
      $statement = $pdo->prepare($sql);
      $statement->execute();
      $user_id = $pdo->lastInsertId();
    }
simplypixie 123 Posting Pro in Training

Sorry, that should have been max-width: 100%;

simplypixie 123 Posting Pro in Training

Sorry for my delays in my replies but I am not receiving notifications for some reason.

An example of the actual link would be http://www.uniteddiesel.co.uk/faqs/what-are-service-exchange-units/

So what-are-service-exchange-units is what is in $faqs['slug']

I have never redirected everything to index.php - it is not how I build and I personally don't like it (just a preference really)

I have just realised though that normally when I have an htaccess redirect that isn't working for some reason I get a page not found but for these I am getting an internal server error which is odd.

** Solved **

Now I realised it was an internal error, I checked the error logs and found the problem was a recursive internal redirect. So I lookd again at the redirect and relaised what the problem was:

I had named the main link the same as the redirect link - stupid error.

All sorted now though

simplypixie 123 Posting Pro in Training

Sorry, not sure what you mean?? Unless you mean RewriteEngine On in which case, yes.

However, it still doesn't make sense that some redirection is working and the other isn't

simplypixie 123 Posting Pro in Training

Set all images to 100% width with a max-width specific to images in specific divs to make sure they don't get bigger than the orginal

img {
    width: 100%;
    height: auto;
}
simplypixie 123 Posting Pro in Training

So what problem do you have now (you don't say)? Also you don't need to declare an array of variables in your execute statement unless you are using placeholders, just use execute()

simplypixie 123 Posting Pro in Training

This is driving me insane - I have certain links that are re-written on a site that work perfectly fine (and I am not new to re-wring urls) but have just found that some others aren't and I cannot fathom out why.

What works:

// The link
<a href="/shop/<?php echo $parent_category['slug']; ?>/products">

// The RewriteRule
RewriteRule ^shop/([a-zA-Z0-9_-]+)/products/?$ /shop/diesel-products.php?slug=$1

What is not working:

// The link
<a href="/faqs/<?php echo $faq['slug']; ?>">

//The RewiteRule
RewriteRule ^faqs/([a-zA-Z0-9_-]+)/?$ /faqs?slug=$1

// Also tried
RewriteRule ^faqs/([a-zA-Z0-9_-]+)/?$ /faqs.php?slug=$1

What am I missing??

Just for reference (if it has any bearing) I am also using .htaccess to accept links without file extensions using:

# show file names without .php extension
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)/?$ $1.php [L,QSA]
simplypixie 123 Posting Pro in Training

I would re-structure to just query on the user and then compare the returned ids to your array of ids

$secondArray = array();
//$ids = join(',', $IdArray);  
$query = "SELECT * FROM test WHERE user = '$user'";
$results = mysql_query($query);
while($row = mysql_fetch_array($results)){
    if (in_array($row['id'], $IdArray)) {
        $secondArray[] = "YES";
    } else {
        $secondArray[] = "No";
    }
}
simplypixie 123 Posting Pro in Training

Passing as an array is exactly what you should be doing. Not sure whee you have heard that passing form data as an array is wrong as that is the only way to pass the data if you have multiple fields of the same 'type'.

simplypixie 123 Posting Pro in Training

Along with a load of bloated, unnecessary code - oh if only it was just used for blogs as it was intended!

simplypixie 123 Posting Pro in Training

SOrry I missed that in your original post.

Firstly I need to suugest that you immediately start ysing mysqli or PDO instead of just mysql as it is now depricated and much less secure than the other two (See Here).
Secondly, you only need to use hostname='', database_name='' etc if using PDO, if just using mysql (or mysqli - just change to mysqli) your database connection should just be:

$marketbase = mysql_connect("hostname","username","password","database") or die("Error " . mysql_error($marketbase));
simplypixie 123 Posting Pro in Training

You shouldn't be using session_register as it is a depricated function. Just assign your session vaiables like

$_SESSION['email'] = $email;
$_SESSION['login_pass'] = $login_pass;

And then check the session is there as @phorce said by using

if(!isset($_SESSION['email'])) {

}

However there are also two other points I would like to make:

  1. Whay would you want to store a password in a session - highly unsafe and no need to

  2. I would suggest using a mulitiple session array so that you can add other variables if required at any time and then unset your session with just one call to the outer array key rather than having to go through and unset them all individually:

    $_SESSION['user']['email'] = $email;
    $_SESSION['user']['id'] = $id; // Just an example
    $_SESSION['user']['username'] = $username; // Just an example

    // To unset
    unset($_SESSION['user']);

    // Rather than
    unset($_SESSION['email'']);
    unset($_SESSION['id']);
    unset($_SESSION['username']);

simplypixie 123 Posting Pro in Training

You are looking at the wrong query - the error message states you have an error near 'ORDER BY m_date DESC' in your original post and then the next error is near 'ORDER BY percent DESC' in a later reply but the query you have posted has no ORDER BY in it at all. So firstly you need to find the correct query that is causing the error as it is not the one you have posted

simplypixie 123 Posting Pro in Training

What is on line 94?

simplypixie 123 Posting Pro in Training

I resolved this by using ajaxForm instead

simplypixie 123 Posting Pro in Training

I have already done all that and I am getting no errors but nothing being passed back either. I can't use Fiddler as I am on a mac

simplypixie 123 Posting Pro in Training

As usual I am having a love hate relationship with jQuery and Ajax :)

I have a PHP file that uploads and resizes and image and stores the data in the database, which on its own works fine. I am now trying to do this through a jquery modal/dialog box using ajax but nothing happens and I cannot work out why (I have tried outputting to console.log but all I get is a blank line - there must be an easier way to debug but hey ho).

My image upload file is:

<?php
require_once('../inc/core.php');
$objProductImage = new ProductImages;

$msg = '';
$errors = 0;

$large_max = 800;
$medium_max_width = 290;
$category_thumb_max_height = 146;
$product_thumb_max_height = 53;

define ("MAX_SIZE","2000");

function getExtension($str) {
    $i = strrpos($str,".");
    if (!$i) { return ""; }
    $l = strlen($str) - $i;
    $ext = substr($str,$i+1,$l);
    return $ext;
}


if(isset($_POST['submit'])) {
    $image = $_FILES["file"]["name"];
    $uploadedfile = $_FILES['file']['tmp_name'];

    if ($image) {
        $filename = stripslashes($_FILES['file']['name']);
        $extension = getExtension($filename);
        $extension = strtolower($extension);

        if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) {
            $msg = '<p class="warning">Unknown Image extension</p>';
            $errors = 1;
        } else {
            $file_size  =filesize($_FILES['file']['tmp_name']);

            if ($file_size > MAX_SIZE*1024) {
                $msg  ='<p class="warning">You have exceeded the size limit!</p>';
                $errors = 1;
            }

            if($extension == "jpg" || $extension == "jpeg" ) {
                $uploadedfile = $_FILES['file']['tmp_name'];
                $src = imagecreatefromjpeg($uploadedfile);
            } elseif($extension == "png") {
                $uploadedfile = $_FILES['file']['tmp_name'];
                $src = imagecreatefrompng($uploadedfile);
            } else {
                $src = imagecreatefromgif($uploadedfile);
            }

            $size = getimagesize($uploadedfile);
            $curr_width = $size[0];
            $curr_height …
simplypixie 123 Posting Pro in Training

This all looks unnecesarily complicated (plus you don't show your db queries so we can see where the problem may be occuring) - have you looked at using PHP's DateTime class / functions?

simplypixie 123 Posting Pro in Training

I have just noticed that you are trying to order by bil but you are not selecting bil in your query. Try the code without the order by first and see if that works.

simplypixie 123 Posting Pro in Training

OK, I think I understand a bit more now (plus I missed off the ON .... from my first query) - you want to return the name of the customer if the search matches their name or their animal's name. If I am correct then your query needs to be

$query=mysql_query("SELECT c.* FROM customers c INNER JOIN animals a ON c.id=a.id WHERE c.name LIKE '".%$search%."' OR a.name LIKE '".%$search%."' ORDER BY c.name ASC");
simplypixie 123 Posting Pro in Training

Not sure what you mean by invert the table name?? What is your query now please.

simplypixie 123 Posting Pro in Training

I agree with @pritaeas but off the top of my head, use DISTINCT in your query to only retrieve one instance of the same value.

simplypixie 123 Posting Pro in Training

You can actually do this in your query instead of PHP

<?php
$dtwarning = mysqli_prepare($db,"SELECT DATEDIFF(tarikh_tamat, NOW()) AS date_diff FROM spoc_pma2012 ORDER BY bil");
$dtwarning->execute();
$results = $dtwarning->fetch_all();
foreach ($results as $row) {
    if ($row['date_diff'] <= 7) {
        echo '<div class="error">
             <p>Warning</p>
         </div>';
    }
}

?>
simplypixie 123 Posting Pro in Training

As @shahidpk has said, use a join but they have missed the search on the animlas table

$query=mysql_query("SELECT c.*, a.* FROM customers c INNER JOIN animals a WHERE c.name LIKE '".%$search%."' OR a.name LIKE '".%$search%."' ORDER BY c.name ASC");
simplypixie 123 Posting Pro in Training

That is what I said in my previosu post :)

simplypixie 123 Posting Pro in Training

That would be because you don't have 'pay' in your url so the $_GET['pay'] is empty as it doesn't exist. I don't see why it is needed so just remove that line.

simplypixie 123 Posting Pro in Training

Looking again, your $submit variables are incorrect, they should be $p and no qutore marks are required. I have amended my post above to correct those ares