broj1 356 Humble servant Featured Poster

Maybe your hosting provider does not allow displaying of errors. Check in web hosting control panel if there is any php or apache error logging.

There is quite a lot of code :-). Have you checked the database is set up correctly or Captcha is correctly used?

It would be good idea to get some code to external files (like Pphp functions, database connection, country selection element etc) which are then just included. It would make code much clearer.

In order you find the cause of the error you should do some simple debugging. I usually put a die statement on various places in PHP code and check if it shows up. Like you could add this on line 180:

die(DB_NAME);

and see if DB name gets displayed. If yes you can carry on between lines 181 and 182 with:

die("Connection: " . print_r($con, 1));

etc.

I will have to carry on tomorrow since it is almost nidnight here :-)

broj1 356 Humble servant Featured Poster

It loads index.php in my browser but shows nothing. Can you post the code? Have you tried error reporting?

broj1 356 Humble servant Featured Poster

Cool. PHP works. You do not have to understand all the info for now :-).

Maybe you post the contents of the index.php. You might have some errors in it.

You can temporarily switch error reporting on by including this on top of your PHP code:

ini_set('display_errors',1); 
error_reporting(E_ALL);
broj1 356 Humble servant Featured Poster

You can run .php in a browser if the server supports it. If it is on a web hosting server, your provider have to support it (and I guess most do). If you run it localy you have to have a correct environment. In Windows it is XAMP or WAMP, on Linux it is LAMP.

PHP is a server side script. The server (such as Apache) processes it and serves resulting HTML to the browser. But the extension is .php.

broj1 356 Humble servant Featured Poster

Please post the whole class structure not only one method.

$Fetch_Assoc, $Fetch_Array, $Num_Rows and $Fetch_Object should be either assigned to some properties or somehow returned by the function. There is a third option which is that these variables were made global but that would defeat the purpose of OOP.

An example (made up, do not copy it):

class $DB_handler
{
    protected $Fetch_Assoc = array();
    protected $Fetch_Array = array();
    protected $Fetch_Object = null;
    protected $Num_Rows = null;

    protected function selectData($table, $where = null, $wheree = null, $where1 = null, $wheree1 = null) 
    {
        $QUERY = mysql_query("SELECT * FROM " . $table . " WHERE '" . $where . "' = '" . $wheree . "' && '" . $where1 . "' = '" . $wheree1 . "'");
        $this->Fetch_Assoc = mysql_fetch_assoc($QUERY);
        $this->Num_Rows = mysql_num_rows($QUERY);
        $this->Fetch_Array = mysql_fetch_array($QUERY);
        $this->Fetch_Object = mysql_fetch_object($QUERY);

    }

    public function getArray
    {
        return $this->Fetch_Assoc;
    }

    public function getAssoc
    {
        return $this->Fetch_Array;
    }
    ...
}

// initialize class
$obj = new $DB_handler;
$obj->SelectData('table_name');
$temp = $obj->getAssoc();
echo $temp['P_id'];
broj1 356 Humble servant Featured Poster

Yes, my index page contains PHP code already (but has a .html extension)

OK, so change it to index.php. It should display html + php script output. If not, check as per iamthwee's suggestion. Mind you there is a small error in his code. Correct code is (see the manual):

<?php
phpinfo();
?>

So if you create a index.php script with only above code it should display the information about the PHP installation. If not check out with the hosting provider support.

broj1 356 Humble servant Featured Poster

I am not sure if I understood you right, but I'll give it a go.

Firstly I think you do not need a $count variable since you have $i for counting. Then you just check the value of $i whether the remainder of the integer division with 10 is 0. If yes, display the banner:

<?php if($i % 10 == 0): ?>
    <div id="banner">
        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
            <!-- SecoundAd -->
            <ins class="adsbygoogle"
            style="display:inline-block;width:710px;height:100px"
            data-ad-client="ca-pub-5699416235054188"
            data-ad-slot="7054710957"></ins>
            <script>
            (adsbygoogle = window.adsbygoogle || []).push({});
        </script>
    </div>
<?php endif;
broj1 356 Humble servant Featured Poster

I hope you din not just copy the code above since it is just a guess (and also contains a typo) - it won't work. Please post the code for the class and how you instantiate it.

broj1 356 Humble servant Featured Poster

Your for loop gets repeated only two times. Did you mean you want to display an ad every 10th match?

broj1 356 Humble servant Featured Poster

I presume $user is the object instatntiated from the class that contains the selectData method. I am guessing that this class stores the results (array, object...) into some properties. Now, you should use correct operators to address those properties, such as:

echo $user->aarrayResultProperty['P_id'];
...

And also:

$QUERY->Fetch_Assoc;

I do not think you can access the $QUERY variable from outside the method.

broj1 356 Humble servant Featured Poster

Te index file should have a php extension only if you have some PHP code in it. Also your web server should have all the neccessary modules instaled and enabled. Which web server are you using?

broj1 356 Humble servant Featured Poster

I've been a long time Eclipse user. Not very advanced usage though, there are still things that I don't quite understand or like. But I like the fact that I was able to switch between Windows (current job) and Linux (previous job, home) environments without much hassle. Also OOP, JS and CSS syntax support are quite OK. Very good for multiple projects handling.

I use Notepad++ for quick edits. The only thing that bugs me is the doubleclick on a variable name won't catch the $ (dollar sign).

broj1 356 Humble servant Featured Poster

You could make it simpler by using file_exists instead of using all the scandir stuff:

$p = $_GET['p']; // WARNING: sanitize this before using it in production app

if (file_exists($dir.'/'.$p.'.htm')){
    include($dir.'/'.$p.'.htm');
} else {
    echo 'Sorry, page introuvable';
}

And sanitize user input (such as limiting it to certain path, whitelisting etc).

broj1 356 Humble servant Featured Poster

This is insecure. You have to sanitize the user input before using it in a select statement.

// suppose the ID is an integer
$id = intval($_GET['id']);
$order = "SELECT * FROM comanda where $id=<some condition here>";
broj1 356 Humble servant Featured Poster

I thought you will post the last version of the code first.

broj1 356 Humble servant Featured Poster

U're welcome :-). Once you have some code and if you get stuck, post the code you have. If you manage to finish it yourself, please mark the thread as solved.

Happy coding.

broj1 356 Humble servant Featured Poster
broj1 356 Humble servant Featured Poster

Your message/notice/title says: Undefined index in php file, but you posted only HTML code, no PHP code. Please post the relevant PHP script that triggered the error (probably the formdata.php, but only you can know).

broj1 356 Humble servant Featured Poster

Also a concern about security on line 8. Instead of:

<input type="hidden" name="id" value="<?php echo $_GET['id'];?>

it should be:

<input type="hidden" name="id" value="<?php echo htmlspecialchars($_GET['id']);?>

to escape possible bad script injection into html.

broj1 356 Humble servant Featured Poster

OK, I gave one line of code as an example and this is the whole snippet:

<?php
  include "db.php";//database connection
   $order = "SELECT * FROM comanda where ['id']=''";
  $result = mysql_query($order);
  $row = mysql_fetch_array($result);
  ?>
  <form method="post" action="edit_reper.php">
  <input type="hidden" name="id" value="<?php echo $_GET['id'];?>
    <tr>        
      <td>Cod</td>
      <td>
        <input type="text" name="cod" 
    size="20" value="<?php echo $row['cod'];?>
      </td>
    </tr>
    <tr>        
      <td>Denumire Material</td>
      <td>
        <input type="text" name="den_material" 
    size="20" value="<?php echo $row['den_material'];?>
      </td>
    </tr>
    <tr>        
      <td>Greutate Totala</td>
      <td>
        <input type="text" name="greutate_totala" 
    size="20" value="<?php echo $row['greutate_totala'];?>
      </td>
    </tr>
    <tr>        
      <td>Name</td>
      <td>
        <input type="text" name="cant_reper" 
    size="20" value="<?php echo $row['cant_reper'];?>
      </td>
    </tr>
    <tr>
      <td>Address</td>
      <td>
        <input type="text" name="lg" size="40" 
      value="<?php echo $row['lg'];?>
      </td>
    </tr>
    <tr>
      <td align="right">
        <input type="submit" 
      name="submit value" value="Edit">

There is still something not OK in the select query on line 3. Something is missing at the where condition, maybe the $_GET (I don't know only you could). Maybe this way:

$order = "SELECT * FROM comanda where {$_GET['id']}=''";
broj1 356 Humble servant Featured Poster

You are almost there. Just remove quotes arround the row elements, add quotes arround row element names, add semicolon at the end and use <?php start tags:

<?php echo $row['den_material'];?>

You might also want to check for errors:

 if($result = mysql_query($order)) {
     // do the stuff...
     ...
 } else {
     // handle error..
 }

Same with the $row = mysql_fetch_array($result) code.

broj1 356 Humble servant Featured Poster

You can check your server side sript if it works OK. Try to input the URL with the parameters into your browser directly e.g.:

php-includes/news_letter_send.php?name=somename&email_address=justme@example.com

You will have to change the global array to $_GET temporarily:

if(isset($_GET['name']) && isset($_GET['email_address'])) {
    $name = $_GET['name'];
    $email = $_GET['email_address'];
        ...
} else {
    die 'failed';
}

You can use different parameters in the query string: the ones that exist in the databse and the ones that don't. The script should echo either duplicate, sent or failed. If this is true your backend script works OK. In this case go and check the jquery ajax code, i.e if the msg gets alerted OK.

Errors could be also in the include file or in the success element.

And one more important thing: you should sanitize the user supplied data (and check for existence of $_POST elements earlier):

if(isset($_POST['name']) && isset($_POST['email_address'])) {
    $name = mysql_real_escape_string($_POST['name']);
    $email = mysql_real_escape_string($_POST['email_address']);
    $sql = "SELECT tbl_news_letters.emailaddress WHERE tbl_news_letters.emailaddress=$email";
    ...

} else {
    die 'failed';
}.

And: drop the mysql database extension and switch to PDO.

broj1 356 Humble servant Featured Poster

This could be quite a complex task and I think you would need some server side scripting (such as PHP) and a database (like mysql). You would also have to look at the PHP forum here but I guess you might get some experience or get someone with PHP and mysql skills to help.

BTW, Moodle is a popular opensource ready-made environment for e-leraning. Would it not cover your needs?

broj1 356 Humble servant Featured Poster

JSFIDDLE shows no code. Anyway, since this is more a CSS question, I suggest you start a new thread in the Web Design, HTML and CSS Discussion part of DW. This way you will have other people looking at it (I guess not many people look at threads with so many posts).

Once this thread is finished, please mark it as solved.

broj1 356 Humble servant Featured Poster

It could be that the kladilnica table is not matched to the field types. Can you post the structure of the table (use SHOW CREATE TABLE kladilnica in phpmyadmin).

And please note: you should sanitize user supplied variables before inserting them into the database.

broj1 356 Humble servant Featured Poster

My fault guys, I did not mean to frustrate anyone

No worries, mate. It's easy to get lost after that many posts :-)

Broj1, it seems that printList($file_names) does echo correctly, it just doesnt go into the array.

OK, but the thing is that you are echoing one thing ($file_names, which is a function parameter), and storing into array another thing (the result array of the glob function). This is why your simplified test above won't yield any useful result.

You have to test the function the way it will show whether the glob function returns valid results which you then store into the array. You can do that by using the die and print_r tricks I showed above. This debugging principle is simple: stop the execution of script using the die function right after the point where you want to inspect some variable and print out the variable using print_r. There are more advanced debugging techniques but at the moment you do not need them.

broj1 356 Humble servant Featured Poster

OK, I am a bit confused now :-). Are you saying the printList() function in above code does not echo anything?

broj1 356 Humble servant Featured Poster

So you think the $tpdf array is empty? Put this code on line 10 in the function above:

die(print_r($tpdf, 1));

This will display the contents of the array after it has been filled with the result of the glob function and stop the script. Please post the result here.

broj1 356 Humble servant Featured Poster

So you think the $tpdf array is empty? Put this code on line 10 in the function above:

die(print_r($tpdf, 1));

This will display the contents of the array after it has been filled with the result of the glob function and stop the script. Please post the result here.

broj1 356 Humble servant Featured Poster

So the glob function does not find any files? To confirm this put the following code immediatelly after line 5:

if($pdf_check == false) {
    die('Error: no matches found');
}

This will return error and stop the script if the glob is a problem. Then you have to check the path you provide to glob function. Post the result here.

broj1 356 Humble servant Featured Poster

The printList() should return a value if you want to use it in assignment (line 3 in the first snippet).

function printList($file_names){
    //print the list
    echo "<p class=cart-list-header ></p>";
    echo "<ul class=cart-list>";
    $pdf_check = glob('pdf/*.pdf');
    $tpdf = array();
    foreach($pdf_check as $pdf){
        $tpdf[] = substr($pdf, 4);      
    }


    foreach($file_names as $file){
        if (in_array($file, $tpdf)){
             echo "'$file',";
        }else{
            echo "<li>$file <span class='red_txt'>(no pdf aviliable)</span></li>";
        }
    }       
    echo "</ul>";

    // I guess this should be returned
    return $tpdf;
}   

Also I have a feeling that you are mixing two functionalities in one function (reading a directory and printing a list from the function parameter). You could split this into two functions.

broj1 356 Humble servant Featured Poster

I am a bit lost now. Can you post the last version of the code.

broj1 356 Humble servant Featured Poster

It is much easier to check the query if you do not use all the concatenation. You can do it this way:

$sql = "INSERT INTO `kladilnica` VALUES ('', '$getUsername', '$betAmouth', '$gain', '$date', '$match1', '$match2', '$match3', '$match4', '$match5','$match6', '$match7', '$match8', '$match9', '$match10', '$match11', '$match12', '$match13', '$match14', '$match15', '$match16', '$odd')";

You have to make sure all the variables are set otherwise you will get an error. It is wise to test the query. Put this code after it:

die($sql);

It will display the query and stop the script. Now you can inspect the query if it is OK and copy it into phpmyadmin to test it.

And a question: are $match1, $match2, $match3... actual fields (columns) in the kladilnica table? Maybe your database design is not scalable.

broj1 356 Humble servant Featured Poster

OK, but I'll have time to look at it tomorrow, hopefuly in the morning.

broj1 356 Humble servant Featured Poster

This script is now different. I thought there are three dropdowns. Have you changed it or did you send me a wrong script?

broj1 356 Humble servant Featured Poster

Form submission page for now, please. So there are two pages now?

broj1 356 Humble servant Featured Poster

Can you post the whole script including the html (form) part.

broj1 356 Humble servant Featured Poster

What is the structure of the users table? You use it to build the first dropdown (for selecting users). I have a slight feeling, that the dailyreport table should not contain the uname and fullname fields since these should be in the users table. Only the uid field should be in the dailyreport table, functioning as a key to connect it to the users table.

broj1 356 Humble servant Featured Poster

In my view the concept you used is OK. I am assuming the form and the PHP code are in the same script. So user can fill in the form to find data from previous months or just leave it blank and get data for the current month. There are few things that are important, but it seems you left them out:

Everytime you tend to use form data stored in the $_GET or $_POST array you have to check whether the element exists using the isset function else you will get an error:

if(isset($_GET["show"]) && $_GET["show"]==1) {
...

Sanitize all and every piece of user data you get from the form and you plan to insert it into the database or use in html on the page (use appropriate sanitization method, provide error handling):

 $month = intval($_POST["select1"]);
 $year = intval($_POST["select2"]);
 ...

Switch to some more modern database extension since mysql_* functions are obsolete. I recommend PDO, also mysqli_* is an option.

There is an error for a result4 query. Correct form might be (se quotes arround the approved word):

$result4 = mysql_query("SELECT uname, (
select SUM(total_sales) \ SUM(total_dialed_leads) * 100
from dailyreport
) as 'sales performance', date FROM dailyreport WHERE sales_status = 'approved'
");
broj1 356 Humble servant Featured Poster

Does the is_category(10) function return true? Test it this way:

if(is_category(10)) {
    echo do_shortcode('[smartslider2 slider="14"]');
} else {
    echo "Error detecting the category page";
}

Now, if it returns the above error message post the is_category() function code.

broj1 356 Humble servant Featured Poster
// $_SESSION['receiver_id'] = 'receiver_id'; <- here need to be ?

This should be between lines 16 and 17 (after querying the database, and uncommented). Or maybe outside this function altogether.

broj1 356 Humble servant Featured Poster

Sorry, have been quite busy lately.

To store the receiver_id into a session variable you only have to read it from the database and assign it to a session variable:

$_SESSION['receiver_id'] = $row['receiver_id'];

But I am not sure if this is useful for you to also store the receiver in the session. Depends on the logic of your app.

broj1 356 Humble servant Featured Poster

PHPClasses has many examples of ready made classes covering various functionalities. A great way of learnig some advanced stuff (by examining the code).

broj1 356 Humble servant Featured Poster

Maybe there is something wrong with your update query (maybe the $sender or $total are not what you expect). You can simply check it by sticking the following piece of code right after line 24:

die($query);

This will display your update query with the parameters and stop the script. Now you can copy the query into phpmyadmin and check if it returns any data.

broj1 356 Humble servant Featured Poster

PHPAcademy if you are more of a visual type of person.

broj1 356 Humble servant Featured Poster

I have been watching this article with much interest hoping that someone will post their solution or ideas. Since there is no much activity so far maybe just a thought or two: if you set up a session handler to use database instead of temp file storage, you might have much better control over each user's sessions. This way when one of the user's sessions is terminated, you can destroy all other open sessions of the same user. I am not sure if this is the best approach, just an idea.

There is some useful info on storing sessions in a database here.

broj1 356 Humble servant Featured Poster

I would use one of jquery UI plugins.

Recommended reading.

broj1 356 Humble servant Featured Poster

It would be much easier if you posted the code in question especially the part arround line 9. Nevertheless, it looks like you are missing a closing ) somewhere.

broj1 356 Humble servant Featured Poster

Haven't studied your code closely but the number 2147483647 is exactly the max integer value on 32 bit systems. Why do you not handle your phone number as a string?

broj1 356 Humble servant Featured Poster

If you want to translate the above ifs into switch correct way as I see it would be:

switch($temp) {
    case 0: 
        echo "it's 0 Celsius"; 
        break;
    default:
        switch($temp > 0) {
            case true: 
                echo "it's not chill outside"; 
                break;
            default: 
                echo "it's chill outside";
        }
}

Another way of doing it would be:

switch(true) {
    case ($temp > 0) : echo "it's not chill outside"; break;
    case ($temp < 0) : echo "it's chill outside"; break;
    default: echo "it's 0 Celsius";
}

But in real situation you do not benefit much from this translation.