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

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

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

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

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

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

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

'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

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

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

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

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
simplypixie 123 Posting Pro in Training

To keep it really simple (unless I am missing something), you could just use

SELECT * FROM trans_table WHERE from_id NOT IN (SELECT mem_id FROM position_table)
simplypixie 123 Posting Pro in Training

Turn on error reporting as if you are getting a completely blank page then something is going wrong in either the code at the top of the page, or one of your include files.

<?php
session_start();

ini_set('display_errors',1); 
 error_reporting(E_ALL);

// rest of code here
?>
simplypixie 123 Posting Pro in Training

It is due to the fact that padding, borders and margins all add to the overall width of the div they are applied to (if you remove all these elements from your content div you will see what I mean). One solution is to add this to the top of your stylesheet (I am not saying this is the correct thing to do)

* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

Otherwise you need to calculate your margins, borders and padding as percentages and reduce the overall width of the div by the total of these percentages.

simplypixie 123 Posting Pro in Training

I might be totally worng, but would you not need to check for both a and b separately

SELECT *
FROM t1
WHERE a NOT IN
    (
        SELECT a
        FROM t1
        WHERE c = 5 AND d = 6
    )
AND b NOT IN
    (
        SELECT b
        FROM t1
        WHERE c = 5 AND d = 6
    )
AND b NOT IN (1, 2, 3, 4)
simplypixie 123 Posting Pro in Training

Unless you are assigning the $_POST['main_category'] to a variable called $main_category_p somewhere that we can't see, then you won't get anything echo'd out. You either need to assign the posted value to your new variable $main_category_p = $_POST['main_category'];or you should be using

if($_POST['main_category'] == "Choose..."){ $_POST['main_category'] = ""; }
echo "$_POST['main_category']";
simplypixie 123 Posting Pro in Training

If you really want to use sub-queries, and presuming you want to show all posts by each user, then this is the sort of thing you will need (I don't know how you want to layout on the page or what your columns are named in your table so have guessed and you will have to adjust accordingly)

$sq= mysql_query("SELECT user_id, username FROM users");

while ($user = mysql_fetch_array($sq)) {
    $sq2 = mysql_query("SELECT * FROM posts WHERE user_id='".$user['user_id']."'");

    echo '<p>'.$user['username'].'</p>';

    while ($posts = mysql_fetch_array($sq2)) {
        echo '<p>'.$posts['title'].'</p>';
        echo '<p>'.$posts['content'].'</p>';
    }
}

If you want to only pull users that actually have posts then combine what you already have with what I have put

$sq= mysql_query("SELECT user_id, username FROM users WHERE user_id IN (SELECT user_id FROM posts)");
simplypixie 123 Posting Pro in Training

Why on earth do you want to store someone's password in a session - no need and very insecure???

Regardless of this, your login is obviously working as you get redirected as per your code, but the username stored in the session is incorrect, nowhere in your script have you set a variable $username, you have only set $username_p, therefore your $_SESSION['username'] = $username will never be populated with any information as it should be $_SESSION['username'] = $username_p.

As a side note, your are duplicating the PHP to check if a user is logged in (it is in both your header file and your index file, which already includes the information from your header file).

simplypixie 123 Posting Pro in Training

Looking at what you have in the other preg_replace functions, shouldn't #[^0-9#]i actually be #[^0-9]#i

With regard to your include files, that is down to you to check the paths to the files are correct I am afraid.

As for the mysql_num_rows issue, your query will presumably not work until you have resolved the preg_replace issue.

simplypixie 123 Posting Pro in Training

This is a big, complex page of code so I think the best thing (rather than keep trying to post bits of it on here) is that I will strip it right back and see if I can find a cause of the problem like that.

simplypixie 123 Posting Pro in Training

Sahil89 - I want to see the 'relevant' code as the poster is saying a width of 100% is creating scrollbars, which it shouldn't, and therefore I want to see the rest of the 'relevant' CSS and HTML (relevant means relevant to the question, i.e. not all of their code) so that I can see what might be causing the scrollbars.

The poster hasn't asked what width to set their page at but has an actual problem with their current code that they need help with which I could possibly help solve if I could see thier code (the same as answering any coding question)!

simplypixie 123 Posting Pro in Training

Please post the relevant sections of your stylesheet and html so we can help.

simplypixie 123 Posting Pro in Training

In your showJobs_new.php page, change this

$sql = mysql_query("SELECT * FROM mytable ORDER BY id DESC $limit" .$where);

To this

$sql = "SELECT * FROM mytable ORDER BY id DESC $limit" .$where;

In fact I can see where your query is wrong now as well - your $where clause must come before your Order By etc, so actually change the code to this

$sql = "SELECT * FROM mytable '".$where."' ORDER BY id DESC '".$limit."'";

As you can see I have temporarily removed the mysql_query from around your query so that you can echo it, therefore underneath this line add echo $sql; and comment out all code beneath so that when you run the page you will get your query displaying in the page. You can then copy the query that has been echo'd out and run it in phpmyadmin (click the SQL tab in phpmyadmin).

kumar.papneja commented: thx, it worked in PHPmyadmin but not in sql code +0
simplypixie 123 Posting Pro in Training

echo your query and then copy and paste into into your phpmyadmin and see what happens there

simplypixie 123 Posting Pro in Training

If you really want to get the whole string after the ? you can use something like:

$id = strstr($_SERVER['PATH_INFO'], '?');
$id = str_replace('?','',$id);
simplypixie 123 Posting Pro in Training

This doesn't do anything:

<form action ="password generator" method="post">

It needs to be a proper file path, like:

<form action ="password-generator.php" method="post">
simplypixie 123 Posting Pro in Training
if (isset($_GET['start'])) {
  $start=$_GET['start'];
}

Read this article to help further.

simplypixie 123 Posting Pro in Training

What you are currently doing is trying to find records where year = '2012, 2011, 201, 2009, 2008' and I would think that you don't have a value like that in your database. I presume you are trying to see if a year matches ONE of the years in your array, in which case do this:

$result = mysql_query("SELECT * FROM VehicleYearModel WHERE year IN ($matches)");
simplypixie 123 Posting Pro in Training

Guessing at the id's that link your tables and not knowing the WHERE cluase:

"SELECT tbl_project.project_name, tbl_delivarables.deliverables, tbl_employee.employee_name FROM tbl_project INNER JOIN tbl_deliverables ON tbl_deliverables.project_id=tbl_project.project_id INNER JOIN tbl_employees ON tbl_employees.employee_id=tbl_deliverables.employee_id WHERE ........"
simplypixie 123 Posting Pro in Training

This is the code I use and run a cron job:

backup_tables('user','password','database');


/* backup the db OR just a table */
function backup_tables($user,$pass,$db)
{

    $suffix = date("mdY-Hi");
  #Execute the command to create backup sql file
  exec("mysqldump --user={$user} --password={$pass} --quick --add-drop-table --add-locks --extended-insert --lock-tables --all {$db} > ../db_backups/backup.sql");

  #Now zip that file
  $zip = new ZipArchive();
  $filename = "../db_backups/backup-$suffix.zip";
  if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
   exit("cannot open <$filename>\n");
  }
  $zip->addFile("../db_backups/backup.sql" , "backup.sql");
  $zip->close();
  #Now delete the .sql file without any warning
  @unlink("../db_backups/backup.sql");
  #Return the path to the zip backup file
  return "../db_backups/backup-$suffix.zip";
}
debasisdas commented: agree +13
simplypixie 123 Posting Pro in Training

Use CSS to set a background colour to rows with errors:

tr.error {
  backround-color: red;
}

Then check if there is an error and if so, apply the style to your table row (replaces line 22 in your posted code):

echo'<tr';

if ($part[2] == 'error') { echo ' class="error"'; }

echo '>';
iamthwee commented: css is the way to go +14
simplypixie 123 Posting Pro in Training

As I put in my original post!

Djmann1013 commented: Thanks +1
simplypixie 123 Posting Pro in Training

I stand corrected - but, I have never once, in all my learning over the years, come across any PHP code that uses the actual words 'and' or 'or' instead of '&&' or '||'

simplypixie 123 Posting Pro in Training

rotten69 didn't change your code for the OR, you cannot use OR in PHP, only in sql queries. So it should be

if($row['banned'] == 1 || $row['banned'] == 2) {
  header ('location: url');
}

You don't need speach marks around numbers/integers as suggested earlier either.

Have you echo'd $row['banned'] to ensure you actually have a value coming from the database?

Also what happens if they aren't banned, surely you should have an else statement following your if for cases like that?

simplypixie 123 Posting Pro in Training

Because you can only access protected properties and methods from the same class or a child class. If you want to access them from outside the class you need to make them public.

andy106 commented: thank you! +0
simplypixie 123 Posting Pro in Training

phorce is correct but they should be the other way around:

<?php

endwhile;

endif;

?>

You are also missing your semi-colon after calling the template_directory

simplypixie 123 Posting Pro in Training

Can you post your array code so I can check it.

If you want to add it to a session, at the top of each page you want to retain the session (including the page where you create it) you must put session_start(); before any other php or html. Then to assign your array to the session you just need something like this:

$_SESSION['aSessionName'] = $yourArrayName;
simplypixie 123 Posting Pro in Training

The holder won't increase when the content of a floated div inside it increases in content as floating a div takes it out of the containing div. What you need to do is create a class to clear the floats and place this after your floated elements inside the holder div.

In your css, add:

.clear { clear:both; }

For the HTML:

<div id="holder">
    <div id="contentleft">
        <p>This is a paragraph. This is a paragraph. This is a paragraph.</p> 
    </div><!--end of contenttop-->
    <div id="contentright">
        Picture go here! Picture go here!Picture go here!Picture go here!
    </div><!--end of contentright-->
    <div class="clear"></div>
</div><!--end of holder-->
simplypixie 123 Posting Pro in Training

I would add them to an array and either store that array in a session or pass it as a variable from page to page.

simplypixie 123 Posting Pro in Training

You have no php tags around your code and you are not using speach marks where needed, try this

<div class="wrapper pad_bot3">
<?php
echo '<figure class="left marg_right1"><img src="'.$row['photourl'].'" alt=""></figure>';
echo '<p class="pad_bot1"><strong class="color2">'.$row['parish'].'</strong></p>';
echo '<p class="pad_bot1"><strong class="color2">'.$row['bedroom'].','.$row['bathroom'].'<br>';
echo ' Price: <span class="color1">'.$row['status'].'</span></strong></p>';
?>
<a href="#" class="button">Read more</a>
</div>
simplypixie 123 Posting Pro in Training

A few things

  1. Why are you using an onclick function to submit your form when there is no need as you are not doing anything complex, just submitting it?
  2. If you are using onclick instead of submit you need to completely remove the action= from your form tag
  3. Where are you assigning your $_POST['ftext'] to your $comment variable as I can't see anywhere and therefore the $comment variable will still be empty as the original declaration?

Looking at your code, this is how I would have it:
<?php

$comment = ' ';

if (isset($_POST) && !empty($_POST['ftext'])) {
    $comment = $_POST['ftext'];
}

?>
<form name = "SentimentForm" method = "POST" action='sentiform.php'>
Input text: <textarea name ="ftext" rows = "10" cols = "50"><?php if(!empty($comment)) { echo $comment; } ?></textarea>
<input type= "submit" value = "Send" name = "btn1">
</form>
<?php if (!empty($comment)) { echo $comment; } ?>
simplypixie 123 Posting Pro in Training

I am not saying that this is what is causing the problem (though it may be) but you have 2 id's named the same (you can only use one id per page, otherwise it needs to be a class):

<div id="navdiv">
			<!--about us submenu list ends-->
		<ul id="navdiv">
simplypixie 123 Posting Pro in Training

You simply need

Select customerNumber From Table1
Where customerNumber NOT IN (select customerNumber from table2)

You don't need to join or select from 2 tables in the main part of your query

haranaboy commented: Thanks for your help +2
simplypixie 123 Posting Pro in Training

Your problem is here

$rows=mysql_fetch_array($sql3);

This should be

$rows=mysql_fetch_array($result3);
karthik_ppts commented: yes +7
simplypixie 123 Posting Pro in Training

@dantinkakkar, I think you misunderstand - I was looking for opinions only as I have been designing/developing using CSS for about 8 years now and already know its benefits. I only asked for opinions as it was a table format and in a sense contains tabular data.

Anyway I went with CSS as the first 2 responders confirmed my thoughts and all is done now.