cereal 1,524 Nearly a Senior Poster Featured Poster

maybe i could do this with aliases?

Hmm, no, because the ErrorLog directive can be set only once for each domain. The easiest solution is to create subdomains for each website and configure indipendent directives.

The CustomLog is used to trace the requests to the server, so it's the access log, you could use an environment variable to trace each website and assign indipendent custom logs, check:

Not tested, but something like this in server or virtual context, should work:

<Directory site1>
    SetEnv subwebsite1
</Directory>

<Directory site2>
    SetEnv subwebsite2
</Directory>

CustomLog ${APACHE_LOG_DIR}/site1.log combined env=subwebsite1
CustomLog ${APACHE_LOG_DIR}/site2.log combined env=subwebsite2
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

set a slave for the log database, then stop the replication, read the data you need and restart the replication:

cereal 1,524 Nearly a Senior Poster Featured Poster

The only thing I have really found is that a master page is like a template?

Yes, but master page is a definition for ASP.Net and Visual Studio (I think), in PHP we (or at least, I would) simply talk about templates.

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Because of this:

<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">

PHP_SELF returns the filename not the query string, to get all the values in the query string then you need also:

$_SERVER['QUERY_STRING']

So:

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING']; ?>">

Or:

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] .'?post_id='. $id; ?>">

Docs: http://www.php.net/manual/en/reserved.variables.server.php

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

It is probably localhost, but check in your Account Manager as suggested here:

cereal 1,524 Nearly a Senior Poster Featured Poster

The parameters order is:

  • host
  • username
  • password
  • database name
  • port
  • socket

Last two are optional, so:

mysqli_connect("host","username","password","db_name");

Docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

Do you mean the html code for my menu?

Yes and also the CSS and the Javascript part. Anyway I've attached a test page based on your code pasted here. Looking at the CSS I see a relevant difference between the file currently online and the version pasted here. Which we should consider? The version you pasted here works fine. Just check the example page attached or test this code (which is the same):

<!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>
    <title>Chamber</title>
    <base href="http://www.ofallonchamber.com/" />
    <script type="text/javascript" src="/SpryAssets/SpryMenuBar.js"></script>
    <style>
    /* The outermost container of the Menu Bar, an auto width box with no margin or padding */

    ul.MenuBarHorizontal

    {
        cursor: default;
        white-space: nowrap;
        display: inline;
        position: relative;
        list-style-type: none;
        font-size: 100%;
        padding: 0px;
        margin-top: auto;
        margin-right: 0px;
        margin-bottom: auto;
        margin-left: 0px;
        clear: none;
        float: left;
        width: auto;
        height: auto;
    }
    /* Set the active Menu Bar with this class, currently setting z-index to accomodate IE rendering bug: http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html */
    ul.MenuBarActive
    {
        z-index: 1000;
    }
    /* Menu item containers, position children relative to this container and are a fixed width */
    ul.MenuBarHorizontal li 
    {
        text-align: left;
        cursor: default;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif, Biondi;
        font-weight: bolder;
        font-style: normal;
        font-size: 100%;
        white-space: nowrap;
        display: inline;
        clear: none;
        line-height: 6px;
        border: 2.4px outset #6688B5;
        padding: 0px;
        position: relative;
        margin: 0px;
        float: left;
    }
    /* Submenus should appear below their parent (top: 0) with a higher z-index, but …
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, I don't understand the scheme, how it works the relation between id and parent?

cereal 1,524 Nearly a Senior Poster Featured Poster

@davy read carefully your script, you have at:

line 5:

$post_id = isset($_POST['post_id']) ? $_POST['post_id'] : '';

line 14 & 15:

if (!empty($_GET['post_id'])){
$result = mysql_query("SELECT * FROM static_page WHERE post_id =".$_GET['post_id']) or die(mysql_error());

line 17:

$post_id = $data['post_ID'];

line 35:

if ( $_POST['post_id'] !=0)

line 41:

$sqlstr = "UPDATE static_page SET page='".$page."', judul='".$judul."', isi_berita='".$news."' WHERE id=".$_POST['post_id'];

So, you are trying to get the value of post_id in three flavours:

$_GET['post_id']
$_POST['post_ID']
$_POST['post_id']

Now, if you are appending the post_id variable to the url used as action in your form, so:

<form method="post" action="http://localhost/free-prowebsite/site_pro/administrator/input_berita_static.php?post_id=1">

Then use $_GET['post_id'] everywhere in your script. If instead you're using an input field in your form:

<form method="post" action="http://localhost/free-prowebsite/site_pro/administrator/input_berita_static.php">

    <input type="hidden" name="post_id" value="1" />

Then use $_POST['post_id'] everywhere in your script, pay attention here: post_id not post_ID which for the server is a completely different variable.

cereal 1,524 Nearly a Senior Poster Featured Poster

If you can upload or paste here a very simplified version of your page (only header and navigation), maybe it will be easier to fix the problem, I've tried my suggestion on your current version and seems to work on Firefox and Chrome, I still didn't tested on Internet Explorer.

Question: which screen resolution are you using?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello, use this format:

data-validation-length="45-60"

Example: http://jsfiddle.net/3XYA4/
& docs: http://formvalidator.net/#default-validators_length

cereal 1,524 Nearly a Senior Poster Featured Poster

It seems we all got down vote, would be nice to know why :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, the problem is given by this:

$abc=mysqli_query($con, $s) or die('cannot show tables');

if($abc)
print_r($s);

The function mysqli_query() returns FALSE on wrong queries, then it returns an OBJECT for SELECT, SHOW, DESCRIBE or EXPLAIN queries, and TRUE for other successful queries, like for example an ALTER query:

$sql = "alter table tbname add type varchar(255) null";

So, the IF condition cannot work correctly for your SELECT query, in this case you must use the function is_object():

$abc=mysqli_query($con, $s) or die('cannot show tables');

if(is_object($abc) === TRUE)
print_r($s);

Or mysqli_errno() which returns 0 when no error occurred, an example:

$mysqli = mysqli_connect("localhost", "user", "pwd", "dbase");
$sql = "select * from tbname";
//$sql = "alter table tbname add type varchar(255) null";
$q = mysqli_query($mysqli, $sql);

echo "<pre>";
echo $q === true ? 'true':'false';
echo PHP_EOL;
echo is_object($q) === true ? 'true':'false';
echo PHP_EOL;
echo mysqli_errno($mysqli) == 0 ? 'true':'false';
echo PHP_EOL;
echo mysqli_errno($mysqli);
echo "</pre>";

var_dump($q);

Docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

PDO supports many databases, where MySQLi is limited only to MySQL and his forks. MySQLi instead has a better support for MySQL features and it can be used also in procedural style.

For more information read the documentation & the comments:

cereal 1,524 Nearly a Senior Poster Featured Poster

Thanks it looks nice but involves writing a construct for each controller.

If you load the library in the autoload.php file then you don't need the constructor. Anyway, helper of library, in this case does not make much difference: when I started writing my first post I didn't read about your decision... :)

cereal 1,524 Nearly a Senior Poster Featured Poster

You could create a library and use it to pull the constants from the database, for example, here the table:

CREATE TABLE `constants` (
  `name` varchar(255) NOT NULL,
  `value` varchar(255) DEFAULT NULL
) ENGINE=MyISAM;

 insert into constants(name, value) values('blue', '#0000ff');
 insert into constants(name, value) values('dodger blue', '#1e90ff');
 insert into constants(name, value) values('deep sky blue', '#00bfff');

 select * from constants;
+---------------+---------+
| name          | value   |
+---------------+---------+
| blue          | #0000ff |
| dodger blue   | #1e90ff |
| deep sky blue | #00bfff |
+---------------+---------+
3 rows in set (0.00 sec)

Create the file consts.php in /application/libraries/ and paste:

<?php

class Consts
{
    private $CI;

    public function __construct()
    {
        $this->CI = & get_instance();
        $this->setConstants();
    }

    private function setConstants()
    {
        $query = $this->CI->db->get('constants');
        foreach($query->result() as $row)
        {
            define((string)$row->name, $row->value);
        }

        return ;
    }
}

In alternative you could dynamically set a config item, so instead of:

define((string)$row->name, $row->value);

You would use:

$this->CI->config->set_item($row->name, $row->value);

In your controller constructor:

class Test extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->library('consts');
    }

In alternative you could place it in the /config/autoload.php.

Finally, in your view:

<?php

    echo blue;
    echo constant('dodger blue');

Or in case of the dynamic set:

<?php

    echo $this->config->item('blue');

To avoid conflicts & problems, I would use a prefix and underscores to replace the spaces, for example, instead of dodger blue:

echo color_dodger_blue;
// or
echo $this->config->item('color_dodger_blue');

BUT, since constants are not meant to change after the installation, I would create a script to …

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
have you tried these instructions?

You must read the setup instructions link in the above document. If it still doesn't work for you, please explain the reason, provide the error codes you get, otherwise we cannot help much.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, you can use multiple submit buttons in your forms:

submit buttons: When activated, a submit button submits a form. A form may contain more than one submit button.

and:

If a form contains more than one submit button, only the activated submit button is successful.

source: http://www.w3.org/TR/html401/interact/forms.html

to access a function in other php file?

Use the action attribute of the form to point a switcher file, there you can redirect or just use include() to perform the pre-selected operation.

Here is an example:

<?php

    $print = '';
    $action = '';

    if($_POST)
    {
        $print = $_POST;

        if(array_key_exists('query', $_POST))
        {
            // do query
            $action = 'query';
        }

        if(array_key_exists('edit', $_POST))
        {
            // edit action
            $action = 'edit';
        }
    }

?>
<!DOCTYPE html>
<html>
<head>
    <title>Yet Another Form</title>
</head>
<body>

    <form method="post" action="">
        <input type="text" name="msg" />
        <input type="submit" name="query" value="search" />
        <input type="submit" name="edit" value="edit" />
    </form>

    <pre><code>
        <?php
            print_r($print);
        ?>
    </code></pre>

    <p>
        <?php
            echo $action;
        ?>
    </p>

</body>
</html>

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

assuming you're using method GET for your form, you need to read the value assigned to $_GET['grupa_select'] and to use it as condition in your select query. So, something like:

$values = array(
    $_GET['grupa_select']
);

$sql = "SELECT * FROM concerts WHERE groupnaziv = ?";

$query = $pdo->prepare($sql);
$query->execute($values);

$result = $query->fetchAll();

foreach($result as $row)
{
    echo $row['mesto'];
    echo $row['datum'];
    echo $row['karte'];
}

Now, when you write:

in database they are called place=mesto, date=datum, and tickets=karte

Do you mean that these are the table or the column names? Please, show us the table structure.

In my example I'm using PDO, because the MySQL API is deprecated and will be removed, I suggest you to read this:

cereal 1,524 Nearly a Senior Poster Featured Poster

Have you tried datepicker from the JQueryUI package?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

actually they seem to use the post ID as local part of the poster email address. So, they receive an email from a user on their servers and, then, they redirect it to the original email address. It works as a relay. But they also create unique aliases for the replies... It can become very complicated, so it depends on your requirements.

To get an idea check out these links:

cereal 1,524 Nearly a Senior Poster Featured Poster

I see it in the right side of the page, not to the left. Anyway you could add an id to the td tag containing the menu, declare it as position:relative and then set top and left for ul.MenuBarHorizontal basing on the parent position, so:

#mymenu001
{
    position:relative;
}

ul.MenuBarHorizontal
{
    cursor: default;
    width: auto;
    white-space: nowrap;
    display: inline;
    position: absolute;
    list-style-type: none;
    top: 0;
    left:0;
    right: auto;
    bottom: auto;
    font-size: 100%;
    margin: 0px;
    float: none;
    height: auto;
    border-top-width: 0px;
    border-right-width: 0px;
    border-bottom-width: 0px;
    border-left-width: 0px;
    border-top-style: none;
    border-right-style: none;
    border-bottom-style: none;
    border-left-style: none;
    padding: 0px;
}

The HTML part:

<td nowrap="nowrap" id="mymenu001">

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello, the Unexpected value translate(NaN,0) problem seems to be generated by the range value:

{"range":"0 - 5","percentage":12,"qty":1326}

which is used to set the x attribute of the rect tag:

<g transform="translate(37.5,0)">
    <rect y="0" x="NaN" height="300" width="36.5"></rect>
    <text x="1" y="-15.78947368421052" dy=".75em">38%</text>
</g>

If you change all the values of your array to range:0, it should work fine. Regarding the first two rows, you don't get them because of:

//2 empty axisses
svg.append("g")
        .attr("class", "y axis");
svg.append("g")
        .attr("class", "x axis");

By commenting these lines you get also 0 and 1 indexes. Example of JSON array:

<?php
header('Content-Type: application/json');
echo '[{
    "range":0,
    "percentage":12,
    "qty":1326
},
{
    "range":0,
    "percentage":38,
    "qty":4311
},
{
    "range":0,
    "percentage":31,
    "qty":3529
},
{
    "range":0,
    "percentage":11,
    "qty":1238
},
{
    "range":0,
    "percentage":3,
    "qty":379
},
{
    "range":0,
    "percentage":2,
    "qty":238
},
{
    "range":0,
    "percentage":1,
    "qty":130
},
{
    "range":0,
    "percentage":0,
    "qty":43
},
{
    "range":0,
    "percentage":0,
    "qty":16
},
{
    "range":0,
    "percentage":0,
    "qty":9
},
{
    "range":0,
    "percentage":0,
    "qty":5
},
{
    "range":0,
    "percentage":0,
    "qty":3
},
{
    "range":0,
    "percentage":0,
    "qty":4
},
{
    "range":0,
    "percentage":0,
    "qty":5
},
{
    "range":0,
    "percentage":0,
    "qty":3
},
{
    "range":0,
    "percentage":0,
    "qty":2
    }]

    ';
?>

Hope it helps you to fix it, my javascript knowledge is not well :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

You can use the required attribute:

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

    <label for="fruits">Choose an option:</label>

    <select name="fruits" required>

        <option value="">------</option>
        <option value="fujiapple">Apple</option>
        <option value="vanillaorange">Orange</option>
        <option value="pandoracherry">Cherries</option>

    </select>

    <input type="submit" name="submit" value="submit" />
</form>

By adding an empty option the form will not be submitted. You could also add a javascript check, but you will always need a server-side validation: you cannot trust what is sent by the client.

Related post:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello, try with:

.dropdown-menu {
    max-height: 450px;
    overflow-y: auto;
    overflow-x: hidden;
}

Source:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

I think the problem is in the cents variable, this is modified after each IF statement, but doing:

cents = cents%0.25;

Will return 0.065 which means 0, so the other statements will return empty. Try:

var calculate_click = function ()
{ 
    var cents = $("cents").value;

    if (cents > 24){
        var quarters = Math.floor(cents/0.25);
        $("quarters").value = quarters
    }

    if (cents > 9){
        var dimes = Math.floor(cents/0.1);
        $("dimes").value = dimes
    }

    if (cents > 4){
        var nickels = Math.floor(cents/0.05);
        $("nickels").value = nickels
    }

    if (cents > 0) {
        var pennies = Math.floor(cents/0.01);
        $("pennies").value = pennies
    }
}

Hope it's helpful, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Sorry for the update, I just noticed that you are using ZF1, the situation is similar, but the code is different and it refers to MySQL, check lines 83 and 104:

/**
 * Creates a PDO object and connects to the database.
 *
 * @return void
 * @throws Zend_Db_Adapter_Exception
 */
protected function _connect()
{
    if ($this->_connection) {
        return;
    }

    if (!empty($this->_config['charset'])
        && version_compare(PHP_VERSION, '5.3.6', '<')
    ) {
        $initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
        $this->_config['driver_options'][1002] = $initCommand; // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND
    }

    parent::_connect();
}

When they get PHP versions lower than 5.3.6, it seems, they rewrite the driver_options with the value of charset. It seems like that value in the application.ini is a default value, it probably could be empty.

From the PHP docs:

charset
The character set. See the character set concepts documentation for more information.
Prior to PHP 5.3.6, this element was silently ignored. The same behaviour can be partly replicated with the PDO::MYSQL_ATTR_INIT_COMMAND driver option, as the following example shows.

cereal 1,524 Nearly a Senior Poster Featured Poster

Regarding the 500 error, check the error log of your server, an external redirect cannot generate an error like that, unless your server config is accepting some headers set from remote.

A part that, if you look at f, c and ch values, these are base64 strings, concatenated by - characters, by splitting them and decoding you can get some random characters, probably due to a particular character encoding... These kind of string can be used to bundle code or images into source codes, but in your case, this is not the reason of the error: it could if the code was appended to the final link, i.e.:

So, I would check the logs of the server, of the database and the source code that generates the dynamic listing. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

The reason is probably given by their PDO library, check lines 266, 320 and 323:

The $options, created by the resources.db.params.driver_options.1002 variable is used as 4th argument in the PDO connection string, for the character set. The $charset variable instead is used at line 323:

$this->resource->exec('SET NAMES ' . $this->resource->quote($charset));

So, it seems they are repeating the command for the pgsql driver. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

here it showing all city values but i need to show state related.

To solve this just change the query at line 28:

$state_id   = $s['state_id'];
$result     = mysql_query("select c.city, c.city_id, (CASE WHEN FIND_IN_SET(c.city_id, cp.city_id) THEN 1 ELSE 0 END) as checked from cities as c, city_place as cp where cp.spaid = {$id}");

With:

$state_id   = $catid; // IMPORTANT
$result     = mysql_query("select c.city, c.city_id, (CASE WHEN FIND_IN_SET(c.city_id, cp.city_id) THEN 1 ELSE 0 END) as checked from cities as c, city_place as cp where cp.spaid = {$id} and c.state_id = {$state_id}");

In practice we are adding the condition c.state_id = {$state_id} to the WHERE clause. This should restrict the result set. Note the change to the $state_id variable, because otherwise you get an empty string and the query does not work fine.

And one more question i have a dropdownbox ...

Always in relation with $id? In this case you can move/copy the same script to the findplace1.php file, add an hidden input field to your form to save the id and add it to the AJAX request. For example, in the JS instead of:

function getPlace(stateId) {        
    var strURL="findplace1.php?city="+stateId;

Write:

function getPlace(stateId) {
    var spaid = document.getElementById('spaid').value;
    var strURL="findplace1.php?city="+stateId+"&id="+spaid;

To the form add:

<input type="hidden" name="spaid" id="spaid" value="<?php echo $id; ?> />

The findplace1.php can be rewritten:

<?php

include("db.php");
$city   = intval($_GET['city']);
$id     = intval($_GET['id']);

$result = mysql_query("select c.city, c.city_id, (CASE WHEN FIND_IN_SET(c.city_id, cp.city_id) THEN 1 ELSE 0 END) as checked …
cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, there are few problems in the above code. The first problem is given by this line:

$ids = array($city_id);

Even if $city_id is a comma separated list, for MySQL it is always a string, so it is for the MySQL API in PHP, and the output generated by the above line is:

Array
(
    [0] => 1,2,3
)

When instead you may want something like this:

Array
(
    [0] => 1
    [1] => 2
    [2] => 3
)

The other problem is at line 11:

echo $latlngStrs = place.split(",",$city_id);

Assuming that place is $place, this will generate:

1,2,3Array

considering this output, the query at line 16:

$latlngStrs[$i]=mysql_query("select city_id from city_place where city_id=$latlngStrs[$i]");

Will try to compare it to the city_place.city_id, so:

select city_id from city_place where city_id = '1,2,3Array';

It will return an empty result set. Then, since split() (which is deprecated) can return an array or a boolean FALSE, but never NULL, the condition at line 24:

$checked = (is_null($latlngStrs)) ? '' : " checked";

will always return FALSE, so you will always get checked.

Now, the script can be solved with a single query which takes the rows from city_place with the same spa.id of the first query and uses FIND_IN_SET to compare cities.city_id against city_place.city_id and returns a checked column, basically:

select c.city, c.city_id, (CASE WHEN FIND_IN_SET(c.city_id, cp.city_id) THEN 1 ELSE 0 END) as checked from cities as c, city_place as cp where cp.spaid = 420;

+------+---------+---------+
| …
cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, but what is the condition to sign the checkboxes? A match between $_GET['place'] and city_id?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

note that you are already overwriting the $ids variable on line 18:

echo $ids = implode(',', $ids);

So, when you try to perform the same action on line 19, you should get a warning like implode(): Invalid arguments passed... because it expects an array, and instead it gets a string: resulting with an empty "string". The other problem is that the second implode is not surrounded by quotes, so the result will look like:

INSERT INTO `city_place` (`state_id`, `city_id`, `spaid`) VALUES('123', 1),(2),(3),(4, 900)

which can be wrong:

  • if you're trying to store multiple values in one single insert query, then you must replicate all the columns into each group of values, so:

    VALUES('123', 1, 900), ('123', 2, 900), ('123', 3, 900)

You must modify your script this way:

$values = array();
$sql = "INSERT INTO `city_place` (`state_id`, `city_id`, `spaid`) VALUES";

foreach($ids as $value)
{
    $values[] = "($city_id, $value, $lid)";
}

$sql .= implode(', ', $values);
mysql_query($sql) or die(mysql_error());

To get:

select * from city_place;
+----------+---------+-------+
| state_id | city_id | spaid |
+----------+---------+-------+
|      123 | 1       |   900 |
|      123 | 2       |   900 |
|      123 | 3       |   900 |
|      123 | 4       |   900 |
+----------+---------+-------+
4 rows in set (0.01 sec)
  • to insert the list in one single column, instead, you have to add quotes:

    sql3 = "INSERT INTO city_place(state_id,city_id,spaid) VALUES ('$cityid', '" . implode(',', $ids) . "', $lid)";

To get:

select * from city_place;
+----------+---------+-------+ …
cereal 1,524 Nearly a Senior Poster Featured Poster

Since in .htaccess the rules have a cascading order, for a simple "manual" solution you could save this .htaccess file into the download directory:

<Files "*">
order allow,deny
deny from all
</Files>

<Files "Myxmlfilename.xml">
order allow,deny
allow from all
</Files>

This would deny the direct access to all the files, except to Myxmlfilename.xml. For a complex solution you could:

  1. separate the files in a public download directory and a reserved, or
  2. deny direct access to the download directory and use a script to serve the files, for example:
cereal 1,524 Nearly a Senior Poster Featured Poster

@faisal

I get both rows, probably you see them on the same line, try to add a separator, for example <br />:

while ($rows = mysql_fetch_array($sql_count))
{
    echo $rows['approved'] . "<br />";
}

Note: the result set is sorted automatically by the IN() function, so it does not matter if you write IN(0,1) or IN(1,0), in both cases will sort 0,1.

Docs: http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#function_in

cereal 1,524 Nearly a Senior Poster Featured Poster

Use group by and count, for example:

select count(approved) from pma where approved in(0,1) group by approved;

live: http://sqlfiddle.com/#!2/f52df/1

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use their test mode:

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

If the invoice numbering goes, for example, from 2009/04/01 to 2010/03/31 then the column year should take both years or the full date string, something like:

2009-2010

Or:

20090401-20100331

Then it can work as you desire:

create table invoices(
    years char(9) not null,
    invoice_number int unsigned not null auto_increment,
    primary key(years, invoice_number)
) engine = myisam;

insert into invoices (years) values('2009-2010'), ('2009-2010'), ('2009-2010');
insert into invoices (years) values('2010-2011'), ('2010-2011');

select * from invoices;
+-----------+----------------+
| years     | invoice_number |
+-----------+----------------+
| 2009-2010 |              1 |
| 2009-2010 |              2 |
| 2009-2010 |              3 |
| 2010-2011 |              1 |
| 2010-2011 |              2 |
+-----------+----------------+
5 rows in set (0.00 sec)

Note: this works on MyISAM engine, but it will not work on InnoDB because this engine requires the auto_increment column in the first position of the primary index key, so:

primary key(invoice_number, years)

To automatically switch the years segments you could use a function, for example this will check if the submitted date is previous of the current 1st of April:

drop function if exists currentyear;
delimiter //
CREATE FUNCTION currentyear(dt datetime)
RETURNS char(9) deterministic
BEGIN
DECLARE result CHAR(9);
CASE WHEN DATEDIFF(dt, CONCAT(YEAR(dt), '-', '04-01')) >= 0 THEN SET result := CONCAT(YEAR(dt), '-', YEAR(DATE_ADD(dt, INTERVAL 1 YEAR)));
ELSE SET result := CONCAT(YEAR(DATE_SUB(dt, INTERVAL 1 YEAR)), '-', YEAR(dt));
END CASE;
RETURN result;
END//
delimiter ;

> select currentyear(now());
+--------------------+
| currentyear(now()) |
+--------------------+
| 2014-2015          |
+--------------------+
1 row in …
cereal 1,524 Nearly a Senior Poster Featured Poster

In addition, you could try with a UDF. For example:

But if you want to save it, you have to use varchar instead of a datetime column.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

you probably want something like this:

<?php

$temps = range(0, 100);

?>

<table>
    <thead>
        <tr>
            <th>Fahrenheit</th>
            <th>Celsius</th>
        </tr>
    </thead>
    <tbody>
        <?php

        if(count($temps) > 0)
        {
            foreach($temps as $F)
            {

                $C = ($F - 32) * 0.55;

                echo "
                <tr>
                    <td>{$F}</td>
                    <td>{$C}</td>
                </tr>
                ";
            }
        }
        else
        {
            echo "
                <tr>
                    <td></td>
                    <td></td>
                </tr>
                ";
        }

        ?>
    </tbody>
    <tfoot>
        <tr>
            <td></td>
            <td></td>
        </tr>
    </tfoot>
</table>
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

the prepare() method requires execute() not query(), so this:

$sql  = "SELECT * FROM user_right WHERE login_id = '$username' and password = '$password'"; 
$stmt = $dbh->prepare($sql); 
$stmt->setFetchMode(PDO::FETCH_ASSOC);
if($stmt = $dbh->query($sql)){
...

Should be:

$values = array(
    $username,
    $password
);

$sql  = "SELECT * FROM user_right WHERE login_id = ? and password = ? limit 1";
$stmt = $dbh->prepare($sql); 
$stmt->execute($values);
$result = $stmt->fetchAll();
$countRows = $dbh->query("SELECT FOUND_ROWS() as total")->fetchColumn();

if($countRows > 0)
{
    foreach($result as $row)
    {
        $_SESSION["username"] = $row['username'];
        $_SESSION["password"] = $row['password']; # to remove
        header("Location:../admin/"); 
    }
}
else
{
    $handleError="user name or password is wrong";
    $_SESSION["errormsg"] = $handleError;  
    header("Location:../notification/errormsg.php"); 
}

Since you're using prepared statement, the query cannot be injected, but the session yes, because you're using:

$username = trim($_POST['username']);

So, it's better to use the result of the query which should be already sanitized and filtered:

$_SESSION["username"] = $row['username'];

also, it's not a good idea to save the password in session, especially if this is not encrypted.

Docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello, have you followed the suggestions you have received in your precedent request?

http://www.daniweb.com/hardware-and-software/linux-and-unix/threads/474312/compile-windwos-netcat-under-linux

If yes, then give us more information about your issue.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

is the URL helper automatically loaded? By enabling the log in CI you should be able to get more information about the error, just check into application/logs/. Try also to prefix the redirect link with a slash, for example:

redirect('/login');
cereal 1,524 Nearly a Senior Poster Featured Poster

You can check the session in the constructor method, for example:

class Test extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();

        # Check the session
        if($this->session->userdata('is_valid') !== TRUE)
        {
            # unset session
            ...

            # redirect out
            redirect('/logout');
        }
    }

    # other methods
    public function index()
    {
        return 'hello';
    }
}

In alternative you can move the check to another controller and then load it on each reserved controller. For example, in application/core/ create MY_Controller.php and paste:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        if($this->session->userdata('is_valid') !== TRUE)
        {
            # unset session
            # redirect out
        }
    }
}

Then in your reserved controller (in this example Test) change this line:

class Test extends CI_Controller

to:

class Test extends MY_Controller

So, each time you open a method of the Test controller, the parent constructor is loaded and the check is performed. Basically you could overwrite only the core controller, but by applying __autoload() to the application/config/config.php as explained in the second link, you can create all the extension you need: MY_Account, MY_Admin, MY_Anonymous and so on...

Docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

Moving the .sql files is the easiest method. But if you encounter such problems there's must be something that interferes with your action.

Have you checked the error log of MySQL?

Can you access the database directory in your server? If yes, you should see infracom_links.ibd and infracom_links.frm by manually removing them you should be able to create the table.

Also this seems related to your problem:

cereal 1,524 Nearly a Senior Poster Featured Poster

The problem seems to be the same of the previous, but it targets a different table. If so it does not seem to be a syntax error.

Can you explain us how do you export and import your SQL files? Are you copying the ibd and frm files as I was supposing in my previous post?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
you could also use a regular expression, for example:

if(/^rgb\(0,\s*0,\s*255\)$/i.test(document.getElementById(id).style.backgroundColor))

Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, I understand the table does not exists, I was suggesting to drop it anyway to force the system to delete the data file, or at least to see if this command would make any difference. The problem happens because you have manually moved the .ibd and .frm files to the database directory:

/var/lib/mysql/project_infracom/

But the id of the table will change in the new database and here starts the corruption. The simplest solution is to manually remove the ibd file from the database directory, so remove infracom_admin.ibd and if it still does not work remove also the frm file. And everything should work fine.

If you perform show tables you can probably see infracom_admin, but if you try to do any action the server will reply that it does not exists, in case the frm file is missing, then you not even see the table name in the result set, but the presence of the ibd file blocks any attempt to create the new table.

Check the documentation to understand how you can move the ibd files between databases, until MySQL 5.5 you have to use the RENAME command, starting from MySQL 5.6 these files are managed differently:

Take especially attention to the 5.5 link, check the last paragraph Portability Considerations for .ibd Files it explains how to perform these operations.

Regarding \G this is only a method to display the results vertically, when you open a connection to the …