cereal 1,524 Nearly a Senior Poster Featured Poster

The command to get just data is:

mysqldump --no-create-info --no-create-db --opt db_name > latest_data_db_name.sql

Otherwise with example 3 you get both create and inserts statements. I use this command line script when I want to backup databases:

<?php

// usage:
// php backup.php [backup type (default 1), [db list (csv list)]]

// example:
// php backup.php 2 project_a,project_b

// the above will backup two databases,
// by omitting the second argument (db list)
// it will backup all databases defined
// in the hardcoded list

$type = array_key_exists(1, $argv) ? $argv[1] : 1;
$list = array_key_exists(2, $argv) ? $argv[2] : FALSE;
$user = '';
$pass = '';

if($list)
    $dbs = array_map('trim', explode(',', $list));

// hardcoded databases list
else
    $dbs  = [
        'db_name',
        'another_database'
    ];

switch ($type) {
    // full, no routines
    case 1:
        array_walk($dbs, function($db) use($user, $pass) {
            exec("mysqldump -u{$user} -p{$pass} $db > full_{$db}.sql");
        });
        break;

    // only create statements
    case 2:
        array_walk($dbs, function($db) use($user, $pass) {
            exec("mysqldump -u{$user} -p{$pass} --no-data $db > create_{$db}.sql");
        });
        break;

    // only data
    case 3:
        array_walk($dbs, function($db) use($user, $pass) {
            exec("mysqldump -u{$user} -p{$pass} --no-create-info --no-create-db $db > data_{$db}.sql");
        });
        break;

    // only routines
    case 4:
        array_walk($dbs, function($db) use($user, $pass) {
            exec("mysqldump -u{$user} -p{$pass} --routines --no-create-info --no-data --no-create-db --skip-opt $db > routines_{$db}.sql");
        });
        break;
}
cereal 1,524 Nearly a Senior Poster Featured Poster

If binlog is enabled maybe you can access the previous queries and reload the old/new database:

But if everything was replaced, due for example to a Windows restore point, then it will not work, you have to try to recover the replaced files, check:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

an easy solution is a mysqldump:

mysqldump --no-data --opt db_name | mysql --host=remote_host -C db_name

This command will dump from local to remote database (remote would be the laptops), the --no-data option dumps only the CREATE TABLE statements, without the insert statements. For each command you have to define also user and password, so it would look more like this:

mysqldump -uUSER -pPASS --no-data --opt db_name | mysql -uUSER -pPASS --host=remote_host -C db_name

But you can dump to a specific file:

mysqldump --opt db_name > latest.sql

then move the file (dropbox for example) and on laptops execute:

mysql -d db_name < latest.sql

For more mysqldump options then check:

cereal 1,524 Nearly a Senior Poster Featured Poster

If linking a stylesheet then you have to define the correct path, not just the file name, unless this is in the same path of the requesting page. In practice change:

$("link").attr("href", "blue.css");

To something like:

$("link").attr("href", "/css/blue.css");

But it's worth to follow previous suggestions and apply a class or some rules rather than downloding new files.

cereal 1,524 Nearly a Senior Poster Featured Poster

So you want to change the DocumentRoot? In that case it can be done only in these contexts:

  • server config
  • virtual host

It cannot be done at .htaccess level. More information here:

cereal 1,524 Nearly a Senior Poster Featured Poster

Click the button at the top right of the page, same level of the title. That should mark the thread as solved.

The sub forums don't exists anymore, for more information check:

And the other threads in Community Feedback forum. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

It should look like:

-> app/
-> public_html/
        -> index.php
        -> ...
-> vendor/
-> bootstrap/

If there is something different then it must reflect in the index.php paths:

require __DIR__.'/../bootstrap/autoload.php';

// and
$app = require_once __DIR__.'/../bootstrap/start.php';

Note I'm referring to 4.2, still not using new version, so there could be some differences.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, because endorsements are tied to forums, and those forums no longer exist or have been rolled up into higher level categories.

That's ok, but profile page still states 74 endorsements, most of them were on PHP (which is now part of Web Development) & Databases. In practice, at the moment, it seems I never got an endorsement in the programming area :D

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

I'm experiencing something similar to ddanbe, I only see endorsements on UI/UX Design (12) and Linux and Unix (10) categories, everything else disappeared.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, which server side language and database are you going to use?

cereal 1,524 Nearly a Senior Poster Featured Poster

Same here on Google Chrome:

Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you should move on public_html only the files that are in the public folder of your laravel application, all the other files should be placed in the parent directory, so that are not accessible by a browser.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can set the result type for fetch_all() which is defined by MYSQLI_ASSOC, MYSQLI_NUM, or MYSQLI_BOTH as explained here and as shown in my previous example:

In any of these cases it will return an array. If for example you would access only the first entry, then you would write:

$rows = $name->fetch_all(MYSQLI_ASSOC);
echo $rows[0]['full_name'];

When using fetch_all() is it fetching the whole table?

It returns only what you have defined in your query, but you get an array with the entire result set. The fetch_array() method instead returns only the first row of the result set, by looping as shown in the example you access all the other entries.

You can test it, do simply:

$row = $name->fetch_assoc();
echo $row['full_name'];

# move internal pointer to get another row
$name->data_seek(2);

$row = $name->fetch_assoc();
echo $row['full_name'];

The same is done, automatically, by the loop.

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

o/

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you have to fetch the results, fetch_all() will return the entire result set:

$result = $name->fetch_all(MYSQLI_ASSOC);
print_r($result);

While fetch_array() will return one row, and in order to get the orders you have to loop:

while($row = $name->fetch_assoc()) {
    echo $row['full_name'];
}

Or move the internal pointer through field_seek() . Check the mysqli_result class for more methods:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

According to the RFC 2109 this seems to be the expected behavior, section 4.2.1:

An origin server may include multiple Set-Cookie headers in a
response. Note that an intervening gateway could fold multiple such
headers into a single header.

And section 4.2.2:

Informally, the Set-Cookie response header comprises the token Set-
Cookie:, followed by a comma-separated list of one or more cookies.
Each cookie begins with a NAME=VALUE pair, followed by zero or more
semi-colon-separated attribute-value pairs. The syntax for
attribute-value pairs was shown earlier. The specific attributes and
the semantics of their values follows. The NAME=VALUE attribute-
value pair must come first in each cookie. The others, if present,
can occur in any order. If an attribute appears more than once in a
cookie, the behavior is undefined.

Link: http://www.w3.org/Protocols/rfc2109/rfc2109

Questions:

  • are you setting the session through session_id()?
  • what is returned by $_COOKIE["PHPSESSID"]?

I ask this because $_SERVER["HTTP_COOKIE"] returns the raw header of Set-Cookie, while $_COOKIE should handle the multiple cookies for you and it should reduce multiple cookies with the same name to only one:

Note that a cookie will replace a previous cookie by the same name in your browser unless the path or domain is different.

Source:

Not sure, but hope this helps.

cereal 1,524 Nearly a Senior Poster Featured Poster

Uh, yes you need the correct privilege in order to perform these changes. Open a ticket with the hosting company and point them to the error message you got from mysqli_connect(), they can fix the issue.

cereal 1,524 Nearly a Senior Poster Featured Poster

It's fine for me, I like it. The only thing that still drives my attention (not disturbing) is the Discussion Starter tag, too purple, if that was gray or outlined like the Featured or the Sponsor tags, I think it would be better.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, I don't understand, could you explain it better and show full code?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, try to round the result of $wd because if for example this is a 4:3 it would return 666,67 i.e. a float, where instead imagecreatetruecolor()expects an integer.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, the ID must be unique, if you have two or more id="anchor-name" then it would not work. If this still does not help then share the code.

cereal 1,524 Nearly a Senior Poster Featured Poster

@JOSheaIV hi, to get the navigation click on the blue icon near the search bar.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, check this link: http://php.net/migration55

P.S. You should read also migrations notes for 5.3 and 5.4, to see what else has changed.

cereal 1,524 Nearly a Senior Poster Featured Poster

Beautiful upgrade Dani!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, if that is a unix timestamp then do:

-- updating date format
UPDATE `table_name` SET `col_name` = FROM_UNIXTIME(`col_name`);

-- changing colum type to datetime
ALTER TABLE `table_name` MODIFY `col_name` datetime null;

If you want to preserve the old value, then add a new column and update against it:

ALTER TABLE `table_name` ADD `new_col_name` datetime null;
UPDATE `table_name` SET `new_col_name` = FROM_UNIXTIME(`col_name`);

More information here:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, run:

SELECT `User`, `Password`, length(`Password`) FROM mysql.user;

The length should be 41, if you get 16 it means that the user is still using the old password system and it needs to be updated. And you have to make sure the system variable old_password is set to 0, otherwise using PASSWORD() will return the same result of OLD_PASSWORD().

More information at:

Adjust the links according to your current MySQL version, as there could be some differences.

cereal 1,524 Nearly a Senior Poster Featured Poster

Good! But I'm not sure I've understood your last request.

cereal 1,524 Nearly a Senior Poster Featured Poster

Does this make sense ??

Uh, ok, it does not work because catid is set in both cases, so it will satisfy always the first condition and stops there. Reverse the rules and it should work:

if(isset($_GET['cat'])) {}

elseif(isset($_GET['catid'])) {}

else {}
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

it does not work it means one of these statements does not run? Which specifically? And by the way: $cat should be $_GET["catid"]?

if(isset($_GET["catid"])) {
    $statement = "posts WHERE cat_name='$cat' ORDER BY pid ASC";

If yes, then simply assign the value to the $cat variable and it should work.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, change:

$target = "upload/";

To:

$target = $_SERVER['DOCUMENT_ROOT'] . "/upload/";

Otherwise move_uploaded_file() will try to write the destination relatively to the script path. Then it should work.

A note: the conditional statements that you're using to detect Javascript, CSS and PHP will mostly fail, as the browser will probably set their mime to text/plain.

I don't see where you set the $uploaded_type variable but I suppose you're using $_FILES['uploaded']['type'], this is not defined by PHP, since is set by the browser it can be altered by the uploader, tricking your statements.

You're using a blacklist approach. In this case you should use a whitelist approach: check only for the allowed types, i.e. the excel mime types:

I would also want to view/edit the file and save the changes.

Have you tried PHPExcel?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, have you checked the encoding returned by the server? You should be able to see it in the Content-Type header response, by using the developer tools in Google Chrome, as explained here:

Or by running curl:

curl -I http://app.tld/page
cereal 1,524 Nearly a Senior Poster Featured Poster

do i need another text editor for the php file?

Hi, it's not required, but using an editor that highlights the code will help a lot. You can try SublimeText with SublimeLinter for syntax checking:

For more suggestions about editors and IDEs search the forum, it has been discussed many times.

If you still have not solved, then share your code here.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, at line 9 of the email.php script do:

// success page
if(mail(...))
    header('Location: http://website.tld/thanks.php');

// error page
else
    header('Location: http://website.tld/error.php');

// stop script execution
exit;

And remove the echo statement at line 11. Docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you could use json or base64, but what happens if you want to search throught collected data? It would be unusable without extra processing. Why don't you normalize the array? Look at section 8 of this tutorial:

cereal 1,524 Nearly a Senior Poster Featured Poster

Very strange, I think it could be the exporter tool but, once imported, the numbers should be managed as floats no matter. What I see is that the default definition of float in the MySQL table will set only 6 digits and round the last, but this should not make a big difference as you stated.

Have you tried to export data directly from sqlite client?

.mode csv
.output /path/to/output.csv
select * from playertimes;
.quit

Then loop output.csv through fgetcsv() or use this script:

<?php

# MySQL credentials
require 'config.php';

/**
 * Set placeholders for batch insert
 * 
 * @param  integer $number
 * @return  string
 */
function set_placeholders($number)
{
    $v = [];

    for($i = 0; $i < $number; $i++)
        $v[] = '(?, ?, ?, ?, ?, ?, ?)';

    return implode(',', $v);
}

# sqlite database, define path
$db1 = new PDO("sqlite:./kztimer-sqlite.sq3");
$q1  = $db1->prepare("SELECT * FROM playertimes");
$q1->execute();
$rows = $q1->fetchAll(PDO::FETCH_ASSOC);

# mysql database
$db2 = new PDO("mysql:host={$db_host};dbname={$db_name}", $db_user, $db_pass);

# batch insert: 200 rows per time
$chunks = array_chunk($rows, 200);
$i = 1;

foreach($chunks as $chunk)
{
    $setp = set_placeholders(count($chunk));
    $q2   = $db2->prepare("INSERT INTO playertimes (steamid, mapname, name, teleports, runtime, runtimepro, teleports_pro) VALUES {$setp}");

    $values = [];

    foreach($chunk as $row)
        $values = array_merge($values, array_values($row));

    $q2->execute($values);

    print 'Rows '. $q2->rowCount() . PHP_EOL;
    print 'Chunk '. $i . PHP_EOL;
    print PHP_EOL;

    $i++;
}

Just set the path to the sqlite database and the credentials to the MySQL database and it should import the table without problems.

However, …

cereal 1,524 Nearly a Senior Poster Featured Poster

Same for me, I ran:

SELECT * FROM `playertimes` WHERE `runtime` BETWEEN 100 AND 200 ORDER BY `runtime` ASC LIMIT 20

And returns in perfect order.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, I understand the data is float but I'm not sure about the column type, is this: decimal, float or double?

cereal 1,524 Nearly a Senior Poster Featured Poster

So,

in the controller you're trying to rewrite the $_FILES array to condition the execution of line 27:

if(!$this->upload->do_upload('file'))

Ok, then replace lines 4, 5 and 6 with:

$files = $_FILES;

foreach($files as $key => $value)
{
    for($s = 0; $s < count($files['file']['size']); $s++)
    {

The $files variable will hold a copy of the original $_FILES array. Otherwise the loop will stop because you're overwriting the $_FILES array and it cannot continue. A test method:

public function upload()
{
    $files = $_FILES;

    print '<h3>Original $_FILES array:</h3>';
    print "<pre>" . print_r($_FILES, true) . "</pre>";

    foreach($files as $key => $value)
    {
        for($s = 0; $s < count($files['file']['size']); $s++)
        {
            $_FILES['file']['name']     = $value['name'][$s];
            $_FILES['file']['type']     = $value['type'][$s];
            $_FILES['file']['tmp_name'] = $value['tmp_name'][$s];
            $_FILES['file']['error']    = $value['error'][$s];
            $_FILES['file']['size']     = $value['size'][$s]; 

            $config['upload_path']   = FCPATH . 'uploads/';
            $config['allowed_types'] = 'gif|jpg|png';

            $this->load->library('upload', $config);
            $this->upload->do_upload('file');

            print "<hr>";

            print '<h3>Rewritten $_FILES array number #'.$s.':</h3>';
            print "<pre>" . print_r($_FILES, true) . "</pre>";

            print "<h3>Upload data:</h3>";
            print "<pre>" . print_r($this->upload->data(), true) . "</pre>";

            print "<h3>Errors:</h3>";
            print "<pre>" . print_r($this->upload->display_errors(), true) . "</pre>";

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

Do you want to extract it from a string or the string is a number itself?

# case 1
$str1 = "Buy 12 apples, 1.5kg of beans and 4 onions, it's already 12:35 hurry up, it's l4t3!";

# case 2
$str2 = '12';

In first case by using preg_match_all() with a simple pattern like this /[\d]+/ you get:

Array
(
    [0] => Array
        (
            [0] => 12
            [1] => 1
            [2] => 5
            [3] => 4
            [4] => 12
            [5] => 35
            [6] => 4
            [7] => 3
        )

)

it will just scan for digits, it's not searching for floats or dates or time and will include the numbers in the word l4t3 (i.e. late), docs:

In the second case use type hint:

$a = (int) $str2;

# or
$b = intval($str2);

which works for integers. You will need floatval() to get decimals. Docs:

Note: please, next time use an appropriate title.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, on line 147:

$sql=("Update improvement_plan set Responsible4='" . $responsible4 . "' WHERE Progressid='" . $_SESSION['Progressid'] . "'");
{

the query function is missing, so there is no update. Also the following curly bracket should not be there as this is used to delimit functions, classes or variables in strings: $a = "hello {$var}";

cereal 1,524 Nearly a Senior Poster Featured Poster

It would be helpful to know how you upload multiple images:

  1. are you using an array?

    <input type="file" name="image[]">
    
  2. or different names?

    <input type="file" name="image_1">
    <input type="file" name="image_2">
    <input type="file" name="image_3">
    <input type="file" name="image_4">
    <input type="file" name="image_5">
    

Because in first case you must loop the $_FILES array to get each image information, for more information follow these instructions:

Or simply print the contents of the $_FILES array to see the format of the received request.

cereal 1,524 Nearly a Senior Poster Featured Poster

At the moment, fix the variable, id & name attributes issues (i.e. avoid repetition), then according to the changes fix your update queries with the new names and then try my first advice:

print the contents of the POST request to see what is actually sent to the script, so on top of the progress.php file simply put:...

run it on both tabs and return the results here.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I suggest you to print the contents of the POST request to see what is actually sent to the script, so on top of the progress.php file simply put:

<?php

    if($_POST)
        die("<pre>". print_r($_POST, true) ."</pre>");

At the moment I see you have duplicated input fields like Progressid, by doing this you get unwanted behaviour as one of the two fields will be overwritten, the same happens with the input field named Position. It is not only related to the name attribute (which, is some cases is allowed: arrays name="Progressid[]" or in radio buttons) but it is also related to the id attribute, that must be unique over the page. In your case Progressid is set two times in the form and the format ProgressidN (where N is $i++) is set in both tabs.

In addition, but not related to the form submission, you're applying the name attribute to div tags, this is not allowed.

Also, you're initializing the session (session_start()) multiple times: set it only once on top of the page, otherwise you won't get the values of $_SESSION, unless the session is already initialized on the portion of code you did not posted.

And finally on lines 3, 119 and 177 you wrote:

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

But I don't see when you set $row for the first time. I think the problem is here: after line 3, on line 19 you have:

while($row = mysql_fetch_array($r))

The function mysql_fetch_array() will overwrite …

cereal 1,524 Nearly a Senior Poster Featured Poster

As I wrote in previous post:

About the headers: if not defined, Node will set implicit headers, but you should always set a status [code|message] response:

https://nodejs.org/api/http.html#http_response_statuscode

cereal 1,524 Nearly a Senior Poster Featured Poster

You use it outside and just add the variable that carries the result of the loop, for example:

$rows = '';

foreach($result as $row)
    $rows .= "
        <tr>
            <td>{$row['article']}</td>
            <td>{$row['price']}</td>
        </tr>
    ";

$content = "

    <p>Display order list:</p>

    <table>
        <thead>
            <tr>
                <th>Item</th>
                <th>Price</th>
            </tr>
        </thead>
        <tbody>
            {$rows}
        </tbody>
    </table>

";

Please: next time define the question outside the code block.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, does it work now?

Applying the end() method after you write the response body is mandatory. About the headers: if not defined, Node will set implicit headers, but you should always set a status [code|message] response:

By the way, you last attempt wasn't working for you because the send() method does not exists in the http module.

cereal 1,524 Nearly a Senior Poster Featured Poster

You should be able to start and stop it as a daemon:

sudo service mongod start
sudo service mongod stop
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, in order to write a response you have to send an header and then call end():

res.writeHead(200, {'Content-Type': 'text/html'});
res.write('2working');
res.end();

Also, probably mistype, on console log you wrote that it listens on port 8080, but it's executing on 8889.

Docs: