simplypixie 123 Posting Pro in Training

You are missing ending semi-colons on some of your lines and also not closing your " on your echos

$p = $h * $r;
echo  "Your Weekly Salary Is: ".$p;



$p = ($h * $r) + (($h - 40) * $r * 1.5);
    echo "Your Weekly Salary Is: ".$p;
simplypixie 123 Posting Pro in Training
.menu {
float: right;
}
simplypixie 123 Posting Pro in Training

Do what urtrivedi has advised and remove all your html and javascript from the php and see if your problem is resolved

while($row = mysql_fetch_array($result)){ ?>

    <div class="BoxContainer">
    <div class="contentBox">
        <span class="inBoxTitle green">A box</span>
        <!-- Demo Button! -->
        <button class="botGreen" id="botSmallPic1">Picture 1</button>
    </div>
</div> <!-- .BoxContainer -->

 <script type="text/javascript">

    // ======== Box
    $("#botSmallPic1").click(function(){
        $.smallBox( 
        {
            title: "",
            content: "",

            color: "#ec008c",
            img: "",
            icon: ""
        }
        );

    });

 </script>

<?php } ?>

And you won't need to call the external js file in your while loop so move <script src="/css/static/js/box.js"></script> to your head

simplypixie 123 Posting Pro in Training

In answer to your first question, just add or statements to your if stament

if ( strpos($matches[2][$k], 'http://mysite.com') === false ||  strpos($matches[2][$k], 'http://localhost') === false)

If I understand your second question correctly

    $multiLinks = array();
    $localhost = 'Assign 1 or 0 here'
    foreach ( $matches[0] as $k => $match ) {
        if ( $post->multiurl_token ) {
            if (($localhost == 0 && (strpos($matches[2][$k], 'http://mysite.com') === false || strpos($matches[2][$k], 'http://localhost') === false)) || ($localhost == 1 && strpos($matches[2][$k], 'http://mysite.com') === false)) {
                $multiLinks[$matches[2][$k]] = $match.coes[3][$k];
            }
        }
        else {
            $multiLinks[$matches[2][$k]] = $matches[3][$k];
        }
    }

Not sure where you are getting the 1 or 0 to assign to your locahost variable so can't provide that bit of code completely.

simplypixie 123 Posting Pro in Training

Sorry to be rude, but surely you can work out that there is a missing closing tag and don't need help with that???

I made a typo:

<tr bgcolor="<?php echo $result2; ?>">
LastMitch commented: You're not rude. You'll absolute right! +9
simplypixie 123 Posting Pro in Training

If that is definitely the correct column name then your formatting is incorrect for the echo and you are missing a ' befoe the closing > of the href.

I always find it best / easiest to keep HTML and PHP separate so can you try this and see if it works

while($row = mysql_fetch_array( $result )) {    
    $result2=($i%2)?'#DFA09D':'white';
}
    <tr bgcolor="<?php echo $result2; ?>";
    <td><?php echo $row['Produk']; ?></td>
    <td><?php echo $row['Jumlah']; ?></td>
    <td><?php echo $row['Tanggal']; ?></td>
    <td>Edit</td>
    <td><a href="hapus.php?P_id=<?php echo $row['P_id']; ?>">hapus</a></td>
    </tr>
<?php
    $i++;
?>
simplypixie 123 Posting Pro in Training

Are you sure that the column in the database is called P_id?

simplypixie 123 Posting Pro in Training

It depends on the format of your date that is being posted (echo out the posted date and check). If it is in any other format other than yyyy-mm-dd then the database won't recognise it and will leave as 0000-00-00.

If it is in a different format then you need to amend the format before saving it to the database

if (isset($_POST['submit'])){

    $date = date('Y-m-d', strtotime($_POST['Tanggal']));

    mysql_query("INSERT INTO Stock (Produk,Jumlah,Tanggal) VALUES ('$_POST[batch]','$_POST[Jumlah]','$date')");

    // Also change your javascript redirect to php:
    header("location: print.php");
    exit();

}
simplypixie 123 Posting Pro in Training

Sorry I missed a bit when checking if a div needs closing

<?php
  $count++;
  if ($count %3 == 0 || $count == $num_images) {
?>
  </div>
<?php  } ?>
simplypixie 123 Posting Pro in Training

OK, starting with the PHP you need to count the images and then check if you need to create a new row (i.e. after every 3 images).

<?php
  $count = 0;
  $num_images = mysql_num_rows($rs);
  while($data = mysql_fetch_assoc($rs)) {
?>
<?php if ($count == 0 || ($count %3 == 0 && $count < $num_images)) { ?>
  <div class="row">
<?php } ?>
  <span>
    <a href="details.php?pic=<? echo $data['id']; ?>">
      <img class="index_pic" width="200" height="200" src="pictures/thumbs/<? echo $data['thumb']; ?>" />
    </a><br>
    <? echo $data['user']; ?>----------- <? echo $data['views']; ?><img src="images/icon_view.gif" />
  <span>
<?php
  $count++;
  if ($count %3 == 0) {
?>
  </div>
<?php  } ?>

The %3 == 0 means if the $count divided by 3 leaves a difference of 0 then you have displayed 3 images in a row and it is time to start a new row.

Then you need to add come CSS to style the row class to ensure it is displayed underneath each time (not sure what CSS you have so can't advise very well, but):

.row {
  width: 100%;
  display: block;
}
simplypixie 123 Posting Pro in Training

You are not using the data returned from your query correctly, please note that any results returned are always in an array, therefore your if else statements should be:

if($omgg['type'] == "Deluxe Floor Room"){$rrate=350;}

Or you can assign the returned result to a variable first:

$type = $omgg['type'];
if($type == "Deluxe Floor Room"){$rrate=350;}
simplypixie 123 Posting Pro in Training

Do you want the number of columns to be set or to be determined by the width available on the screen?

simplypixie 123 Posting Pro in Training

LastMitch - thank you for the Mod Rewrite Generator. I have never seen that before and will make my life so much easier - woohoo :)

simplypixie 123 Posting Pro in Training

There are a couple of errors in your code ( to execute you need to prepare first and your execute should be $stmt->execute(), not $stmt = $pdo->execute())

I actually find using foreach with PDO tends to work better for some reason. I would also agree with diafol that you should separate your PHP and HTML but I would go even further than he has

<?php
$pdo = new PDO('mysql:host=localhost;dbname=contisec_portal', 'root', '');
$sql = "SELECT dateid FROM date_header";
$stmt = $pdo->prepare($sql);
$stmt->execute();

$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

if ($stmt->rowCount() > 0) { ?>
  <select name="fileselect">
    <?php foreach ($results as $row) { ?>
      <option value="<?php echo $row['dateid']; ?>"><?php echo $row['dateid']; ?></option>
    <?php } ?>
  </select>
<?php } ?>

This is not tested

simplypixie 123 Posting Pro in Training

If you are mixing AND and OR in your queries you need to group them into parenthesis

SELECT * FROM contact WHERE  status = '1'
AND lower(concat(nume,' ',prenume)) LIKE '%test%' 
AND (lower(concat(prenume,' ',nume)) LIKE '%test%'                                   
OR functie LIKE '%test%' 
OR email LIKE '%test%' 
OR compartiment LIKE '%test%' 
OR email LIKE '%test%' 
OR user_sap LIKE '%test%'
OR atrib LIKE '%test%'
OR user_mtr LIKE '%test%' 
OR interior LIKE '%test%' 
OR mobil_firma LIKE '%test%') 
ORDER BY nume, prenume LIMIT 7
simplypixie 123 Posting Pro in Training
  1. I have to disagree with zoidmaster - do not use relative or absolute positioning and z-index unless absolutely necessary, there are easier and less buggy ways to position the content in your pages.

  2. If you are going to use % or ems (but ems is better for font sizes) then you need to set a starting font size in your body (even though most browsers have a default size of 16px it is not the same across all so set your required default font sixze in your body element).

  3. Don't jus tuse 'div' to create styles - make sure that each style you specify has a specific name so you know what it is used for and it doesn't get applied to every div on the page. So looking what you have done, maybe call it .wrapper or .container.

  4. Even though you can probably get away with just border-radius nowadays, it makes sense to still specify it with the moz and webkit prefixes for the time being, just in case:

    -webkit-border-radius: 60%;
    -moz-border-radius: 60%;

  5. Unless you set the text-align to anything other than left in the containing box of a child div in the page then you don't need to specify text-align: left; . Also, try not to repeat yourself (in code this is called DRY Don't Repeat Yourself) - so rather than set text-align: center on two different classes, make a separate class just for aligning text to the center and apply that class (along with the main …

EvolutionFallen commented: Good points across the board +4
simplypixie 123 Posting Pro in Training

Try adding cellpadding=0 and cellspacing=0 to your table element:

<table width="100%" border="0" cellpadding="0" cellspacing="0">
simplypixie 123 Posting Pro in Training

'On a non-object' means that you haven't instantiated a class and therefore no object has been created.

Looking at your code though the function you are trying to use is just a function, it is not within a class and therefore you cannot use -> to access the function (that is for classes / objects only).

To access the function, you just need to use add_content($p);

If you are getting the error Call to undefined function mysql_real_eacape_string() It is because you cannot use that function until you have made a connection to your database so check that you connection has been made before running the function.

simplypixie 123 Posting Pro in Training

Oh wow - that works brilliantly and so much easier than trying to work it all out in PHP plus hase saved me a few lines of code. Thank you diafol :)

simplypixie 123 Posting Pro in Training

Thanks, I will have a look at that - to be honest I have very rarely used date functions in my queries as have just stuck to doing it in the PHP after years of doind it that way :)

simplypixie 123 Posting Pro in Training

Because I need all events shown and then highlight the closing date if it is less than 7 days so I can't just query for events that close in less than 7 days.

simplypixie 123 Posting Pro in Training

It's OK, I have it sorted (as usually happens after I post on here) and for one I had missed the date() parameter, but if anyone is interested, I now have

$closing_date = strtotime('-7 day', strtotime($show['closing_date']));
$current_date = strtotime('+7 day', strtotime(date('Y-m-d')));
if ($closing_date < $current_date) { ..... } ?>
simplypixie 123 Posting Pro in Training

My brain won't work (in fact it doesn't often when it comes to comparing dates). I need to check whether a date returned from the database is 7 days or less from the current date (can't do it in database as it is used to highlight events where entries close within 7 days or less).

What I have for now (which isn't working quite as expected) is:

$closing_date = strtotime('-7 day', strtotime($show['closing_date']));
$current_date = strtotime('Y-m-d');
if ($closing_date > $current_date) { .... }
simplypixie 123 Posting Pro in Training

What I am thinking is that you will have a list of records from the database that you will click on to view further information, so in the first instance you would select all rows or a set number of rows (we will go for all for the time being as this is just to get things working as you require and you currently don't appear to have too many records).

First page - get all records from the db

<?php 
  $sql = mysql_query("SELECT * FROM data_employees ORDER BY name ASC");
  while($data = mysql_fetch_array($sql)){
?>
  <p><a href="details.php?id=<?php echo $data['id']; ?>><?php echo $data['name']; ?></a></p>
<?php } ?>

details.php

<?php
  if (isset($_GET['id'])) // Check id has been passed in URL
  $id = mysql_real_escape_string($_GET['id']); // Prevent injection
  $order = mysql_query("SELECT * FROM data_employees WHERE id='$id' LIMIT 1");
  $result = mysql_fetch_array($order);
  $name = $result['name'];
  $address = $result['address'];
?>
<p>Name: <span style="text-decoration:underline;"><?php echo $name; ?></p>
<p>Address: <?php echo $address; ?></p>

I agree with broj1 that you should look at using mysqli or PDO (I have not used here as just putting it in place will confuse you as your database connection needs to be relative to whichever you choose to use before you can use it for queries etc).

simplypixie 123 Posting Pro in Training

The id in your table needs to be set to Auto Increment and that will then mean every time you add a new record that database will assign the next appropriate id for you to that record.

With regard to selecting one record only

<?php
$id = // Assign the id you want to get from the database (I can't tell you how as not sure how you are sending data to this page
$order = mysql_query("SELECT * FROM data_employees WHERE id='$id' LIMIT 1");
$result = mysql_fetch_array($order);
$name = $result['name'];
$address = $result['address'];
?>

<p>Name: <span style="text-decoration:underline;"><?php echo $name; ?></p>
<p>Address: <?php echo $address; ?></p>
simplypixie 123 Posting Pro in Training

I've already said that :)

simplypixie 123 Posting Pro in Training

This is all pointing to an error in your query which I would say is the fact that you are trying to select all from table c but you don't define table c and your are not joining to to. Firstly try removing c.* from your query and see if it works.

If it works and you do need to select all from table c then you need to add in that table and a join to get the data (you will need to adjust the code below as I don't know what your table c is actually called so I have called it customers and presuming you will join between the id in the customers and users tables):

$q = mysql_query( "SELECT u.*,c.* FROM users u INNER JOIN customers.c ON c.id=u.customer_id WHERE u.hospital > 0 ORDER BY u.hospital DESC" , $c ) or die ( mysql_error() );
simplypixie 123 Posting Pro in Training

It's OK, I seem to have sorted it (not entirely sure how, but lots of fiddling).

simplypixie 123 Posting Pro in Training

Anyone???

simplypixie 123 Posting Pro in Training

I thought I had this sorted on another website but just can't resolve the problem now.

I have a link that when clicked shows a form. The form is submitted through jquery ajax, runs the PHP and updates the html in a div on success. All fine.

However, after the ajax call the click functions stop working and I cannot work out why. The html and form are (in short, and the action of the form is retained in case the user has javascript disabled):

<p><a href="#" id="forgot-username">Forgotten Username</a></p>
<div id="forgot-login">
  <form name="get-username" id="get-username" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="hidden" name="to_do" value="Get Username">
    <label for="email">Email</label>
    <input type="email" id="email" class="required" name="email" value="<?php if(isset($_POST['email'])) { echo $_POST['email']; } ?>">
    <input type="submit" value="Get Username">
  </form>
</div>

The jquery and ajax is:

$('#forgot-username').on('click', function(e){
  e.preventDefault();
  $('#forgot-login').toggle();
});

$("#get-username").submit(function(e){
  e.preventDefault();
  var dataString = $(this).serialize();

  $.ajax({
    type: "POST",
    url: "login-logout.php",
    data: dataString,

    success: function(data){
      $('.success-notice').html('<p>'+data+'</p>');
      // bindBehaviours(); 
    }

  });
  return false;
});

The bindbehaviour function call is also something I have tried, by wrapping the click events in this function and trying to trigger it on ajax success.

I have also tried chaning the .on('click'.... to have a second parameter to reference the id and/or link (I have tried various ways) but that stops the event handler working at all.

EDIT: I have just re-loaded the page, clicked on the link, closed the form again and when I click the link again, nithing happens so this doesn't appear to be an …

simplypixie 123 Posting Pro in Training

No problem, glad I could help. Please mark as solved :)

simplypixie 123 Posting Pro in Training

What about trying your query like this (I have removed the NULL values as they are not required for your id column)

if($_POST["Submit"]=="Submit"){ 
        mysql_query("INSERT INTO tblUser VALUES ('$fname', '$lname')"); 
        $new_id = mysql_insert_id();
        for ($i=0; $i<sizeof($checkbox);$i++){ 
        $sql2=mysql_query("INSERT INTO tblItems VALUES ('".$checkbox[$i]."', '$new_id')"); 
        } 
    }
simplypixie 123 Posting Pro in Training

In which case your echo statement is incorrect, try

$ss = $_POST['qty'];
echo "<div id='dialog01' title='ccc'>".$ss."</div>";
simplypixie 123 Posting Pro in Training

$_post is incorrect as always needs to be in upper case so change to $_POST

simplypixie 123 Posting Pro in Training

Works fine for me - are you sure you just have the navigation in your external file, like this?

<div class='navi'>

<ul class='item'>
<li><a href=''>Birthday</a></li>
<li><a href=''>New Baby</a></li>
<li><a href=''>Anniversary</a></li>
<li><a href=''>Wedding</a></li>
<li><a href=''>Driving Test</a></li>
<li><a href=''>Moving</a></li>
<li><a href=''>New Job</a></li>
<li><a href=''>Retirement</a></li>
<li><a href=''>Good Luck</a></li>
<li><a href=''>Engagement</a></li>
</ul>

</div>
simplypixie 123 Posting Pro in Training

Thanks diafol, I used .live('click', function......) instead on the edit button which has worked (already done before I saw your post).

simplypixie 123 Posting Pro in Training

All working nicely :) Just got to work out how to get the click function for the dit button working again after re-loading the div (will post in Javascript forum). Thanks diafol for the idea :)

simplypixie 123 Posting Pro in Training

Thank you diafol, unfortuantley you have confirmed my worst fears :) I just hoped someone might have an answer without me having to re-instantiate the class but hey ho.

I do like your idea of only reloading the include files and re-instantiating if the data returned shows an ajax request and will at the very least implement that.

Squidge - that was my question, can I re-call the class method without having to re-include and re-instantiate.

simplypixie 123 Posting Pro in Training

This is driving me mad. I am using jquery and ajax to run the php to update my database and that all works fine, but after the update (specifically adding records) I want to re-run the query to get all records so that the new one is displayed but nothing happens and in my error log I am getting an error regarding my class instantiation and objects (this is partly a jquery/ajax problem I suppose as well).

The main page (form shortened for ease of reading):

<?php
    require_once('../../inc/core.php');
    require_once('../../inc/class.faqs.php');

    $objFAQ = new Faqs;
    $cats = $objFAQ->get_faq_categories();

    include('../../assets/layout/header.php');

?>

    <div class="container">
        <div class="success-notice"></div>
        <div class="add-record">
            <form action="admin-faq.php" method="post" id="add-faq">
                <label for="question">Question</label>
                <input type="text" name="question" id="question" value="">.
                .
                .
                <input type="submit" name="do_add" value="Submit">
                <button class="close-form" value="Cancel">Cancel</button>
            </form>
            <hr>
        </div>
        <div id="faq-records">
            <?php include('faq-records.php'); ?>
        </div>
    </div>
<?php
    include('../../assets/layout/footer.php');
?>

The faq-records.php file (form shortened for ease of reading - this all works fine on page load):

<?php
    $faqs = $objFAQ->get_admin_faqs();
    foreach ($faqs as $faq) {
?>
    <div class="faq">
        <p><?php echo $faq['question']; ?></p>
        <div class="edit-record">
            <form action="admin-faq.php" method="post" id="edit-faq">
                <input type="hidden" name="id" value="<?php echo $faq['id']; ?>">
                <label for="question">Question</label>
                <input type="text" name="question" id="question" value="<?php echo htmlentities(stripslashes($faq['question'])); ?>">
                .
                .
                <input type="submit" name="do_edit" value="Submit">
                <button class="close-form" value="Cancel">Cancel</button>
            </form>
        </div>
        <hr>
    </div>
<?php } ?>

And the jquery / ajax (as I say this all works apart from the load function, however if I load a basic html file with a line of text that does work):

$("#add-faq").submit(function(e){

        e.preventDefault();
        var dataString = $("#add-faq").serialize();
        var …
simplypixie 123 Posting Pro in Training

If I understand correctly what you are trying to do, why on earth do you have 2 separate databases for your albums and images rather than 2 tables in one database?? There are other errors in your code, firstly $images[$i] = $row[0]; which will just keep populating your images array with the first result from your query results as you only ever assing the value at position 0. Secondly you cannot use table names like FROM $images[$q] as that would try and select from a table called, for example, FROM tablename[0] and as you cannot name tables like that, it just won't work.

What I suggest is chaning your db structure to one database with all your required tables and then you have 2 options to get your albums and related photos. The first is to run a nested query and while loop:

<?php 
    $con = mysql_connect("localhost","root","");
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

mysql_select_db("new_db_name", $con);

$query="SELECT id, album FROM albumname ORDER BY RAND() LIMIT 9";

$result= mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){
    $query2="SELECT Location FROM photos WHERE id='".$row['id']."'";
    $result2 = mysql_query($query2) or die(mysql_error());
    echo $row['album'].'<br>';
    while ($row2 = mysql_fetch_array($result2)) {
      echo $row2['Location'].'<br>';
    }
}

mysql_close($con);

?>

The second way is to use a join but may confuse you even more at the moment so I will leave it to you to decide and look into further if you wish.

simplypixie 123 Posting Pro in Training

Your query is formatted incorrectly, it should be

$sql="UPDATE `$tbl_name` SET `works` = `works` + 1 WHERE `id` = '".$id."'" or die(mysql_error());
simplypixie 123 Posting Pro in Training

You still haven't used the two equal signs as I said you need to but also, why not simplify things by doing your code liike this (also added some missing {} as you are mixing using them and not using them, bad preactice)

<?php
    session_start();
    include 'connect_to_mysql.php';
    $email = $_POST['email'];
    $password = md5($_POST['oldpass']);
    $newpassword = md5($_POST['newpass1']);
    $confirmnewpassword = md5($_POST['newpass2']);
    $query = mysql_query("SELECT password FROM members WHERE email='$email'");
    if(!$query)
    {
        echo "The email you entered does not exist";
    }
    else {
        $result = mysql_fetch_array($query);
        $currentpassword = $result['password'];
        if($password != $currentpassword)
        {
        echo "You entered an incorrect password";
        }
        if($newpassword == $confirmnewpassword) {
            $sql=mysql_query("UPDATE members SET password='$newpassword' where email='$email'");
            if($sql)
            {
                echo "Congratulations You have successfully changed your password";
            }
            else
            {
                echo "The new password and confirm new password fields must be the same";
            }
        }
    }
?>
simplypixie 123 Posting Pro in Training

I haven't looked at everything as you have one major glaring problem and that is your HTML structure - your head tag is supposed to close before your body tag opens, the body tags DO NOT go inside your head tags:

<!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Change Password</title>
    <style type="text/css">
    body, table {font-family:Arial, Helvetica, sans-serif; font-size: 12px; color: #000 ;}
    </style>
    </head>
    <body>
    .
    .
    .
    </body>
    </html>

Sort this first.

simplypixie 123 Posting Pro in Training

Further to all the other error corections you have received above, to check one variable equals another you need to use == not just = so change:

if ($newpassword == $confirmnewpassword)
simplypixie 123 Posting Pro in Training

Looks fine to me (Chrome on Mac). Have you thought it may just be the scrollbar making it appear this way?

simplypixie 123 Posting Pro in Training

I think we are both confused here. From how I read it you wanted to find all pos_id from one table (I don't know that table name as not provided so I have called it table1) that do not exist in the position_table, in which case your query would be (as I originally put)

SELECT * FROM table1 WHERE pos_id NOT IN (SELECT pos_id FROM position_table)

However, what you have written in the new query is something else and if you already have the numbers you want to check against, you can simply do

SELECT * FROM table1 WHERE pos_id NOT IN (100000014, 100000015, 100000016, 100000017, 100000018, 100000019, 100000020, 100000021, 100000022)
simplypixie 123 Posting Pro in Training

showman13 - In your original post you wrote:

What I need is a way to determine if any of the 9 positions don't exist yet, by virtue of there not being a record in the position table with that pos_id...
And what I posted would do that in the simplest way.

simplypixie 123 Posting Pro in Training

I am very confused by your post and am thinking that what I am about to reply is incorrect as seems too simple, but here we go anyway just in case:

SELECT * FROM table_name WHERE pos_id NOT IN (SELECT pos_id FROM position_table)
simplypixie 123 Posting Pro in Training

When inserting records you don't need a value for the id so your query should just be

 $sql = "INSERT INTO content VALUES('$title', '$body')";
simplypixie 123 Posting Pro in Training

The CSS I gave you for box-sizing is supposed to be at the top of your CSS on its own, not in one of your other divs (which is why it has the star, not a div name as it is to apply to everything in the website) so take it out of #content.

* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
color:#414141
}

/* The rest of your CSS here