Isaac_4 39 Junior Poster in Training

After your main loop possibly just do another loop to go from 1 - $max_id and tar up then rm -rf each lower numbered directory?

Maybe I'm missing something but it seems like you're 99% there.

Make sure you make a complete backup of your directory before testing anything that deletes files. Make sure the tar files contain the files you think they do. Make sure the right directories are deleted.

Isaac_4 39 Junior Poster in Training

The plugin itself is not that important. Make sure that your site:

1) Works well with the social media sites you use (e.g. pulls in the right thumbnail and summary text when you share a page)

2) Write good content that is relevant to your target market

There are dozens of ways you can accomplish this, and it's easily done with the built in tools.

Isaac_4 39 Junior Poster in Training

Just wanted to comment that I recommend strongly using prepare and execute instead of escaping strings, as that is a very error-prone method and may lead to SQL injections. See this code snippet for an easy to use function you can use instead.

Isaac_4 39 Junior Poster in Training

You may have done this but often I find a reboot or two resolves this type of issue for me. Open up Settings > Windows Update and click Check for updates, wait for it to finish, then reboot. Do this twice and it is likely to clear up, otherwise it may just be something that takes longer to download. If it does go on for longer then you may have a more serious issue indeed.

Isaac_4 39 Junior Poster in Training

You should mention what your goals are -- e.g. what do you want this site to accomplish, what process or existing manual system does it replace -- and try to list a few sites that do similar things online that you have found, otherwise it would be really hard to provide any guidance.

Isaac_4 39 Junior Poster in Training

Agreed that more context is needed in general.

What type of object is chart1?

One thing I noticed is that displayData_Event is invoked by DataReceivedHandler but this seems to not do anything.

It might be that you need to ask the chart to refresh itself (can't really be sure without knowing what chart you're using).

In general I'd try just a simple form with one chart and a timer that plots a new random value every second to make sure you can draw charts correctly, then try to hook it up to the serial port code.

Isaac_4 39 Junior Poster in Training

The general approach is to do two queries.

Since you didn't include the code that generated your result set, I will use a simple example.

The idea is to do a SELECT COUNT(*) query to figure out how many rows there are in the table, then do a separate SELECT * query to get the current page of data.

<?php

$where = '1=1'; // If you have any conditions in your query, include them here
$perPage = 25;
if(isset($_GET['p'])) {
    $page = (int)$_GET['p']-1; // Get the page selected
} else {
    $page = 0;
}

$countSQL = 'SELECT COUNT(*) As total_rows FROM table_name WHERE '.$where;
// Now get the current page of text
$pageSQL = 'SELECT * FROM table_name WHERE '.$where.' LIMIT '.($page*$perPage).','.$perPage;
$query = mysql_query($countSQL);
$pageCount = $query['total_rows'] / $perPage;
$query = mysql_query($pageSQL);

Now you'll have a populated query object and a pageCount variable telling you how many pages there are.

Add something like this to the end of the page, under your table to render a list of pages:

<p>
Page:
<?php

for($i = 1; $i <= $pageCount; $i++) {
    echo '<a href="?p='.$i.'">'.$i.'</a> ';
}
?>
</p>

This code isn't tested but should be very close to what you need to do.

See this page for info about MySQL LIMIT http://www.mysqltutorial.org/mysql-limit.aspx

Isaac_4 39 Junior Poster in Training

Looks like maybe a simple typo, you open a file named "modifiedrecords." (without any extension) then try to rename a file named "modifiedrecords.txt" to "newrecords.txt".

rproffitt commented: Eagle eye. +12
Isaac_4 39 Junior Poster in Training

If there is an existing AC connection between the two buildings you may be able to get by with an ethernet over powerline adapter such as http://www.amazon.com/TP-LINK-TL-PA4010KIT-Powerline-Adapter-Starter/dp/B00AWRUICG/ref=sr_1_3?ie=UTF8&qid=1457965921&sr=8-3&keywords=ethernet+over+power

Isaac_4 39 Junior Poster in Training

If I am guessing correctly, you are just trying to get some basics to work before you implement the actual functionality. There's nothing wrong with that!

The problem basically is just that you need to declare the $title variable as global in each of the functions that references it. I would do away with the set_title function completely and change get_header:

<?php
function get_header(){
    global $title;
    include 'header.php';
}
function get_footer(){
    include 'footer.php';
}

Then in header.php:

<!DOCTYPE html>
<html>
<head>
    <title><?php echo $title; ?></title>
    <meta charset="UTF-8">
    <meta name="description" content="Photography site" />
    <meta name="keywords" content=" Angelic Photography" />
<!--    <link rel="stylesheet" href="assets/css/main.css"/>-->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
     <link rel="stylesheet" href="assets/css/grayscale.css"/>
</head>

The key thing to remember is that when you include() or require() a file, the code in it is processed exactly as if you had pasted in that code in the same position as the include() call in the parent file. In this case, that means that in order to access the $title variable you either have to use a global or pass it in as an argument.

A better approach
You may want to consider not relying on globals at all, however, in which case you would want to pass the page data to the get_header() and get_footer() functions like this:

<?php
/**
 * Render the header markup for a basic page.
 * @param $page array of data for the page.
 * @return nothing
 */
function get_header($page) {
    include 'header.php';
}

/**
 * Render the footer markup …
Isaac_4 39 Junior Poster in Training

Cache in the PHP level is not going to help in this case. The person at your hosting company was probably either talking about browser caching, or didn't really have a good answer to give you.

Allowing the users to upload the files is fine, but you need to resize them before you include them on a page. PHP has a bunch of built in functions in the GD and ImageMagick libraries that can do this. If you can't quite figure it out, I can write a function for you later tonight or torrow and show how I do it.

For the YouTube video ID you probably want to use explode() or preg_match() depending on how fancy you want to get.

SimonIoa commented: Thanks Isaac +2
Isaac_4 39 Junior Poster in Training

Yeah, as I suspected this isn't to do with your PHP code at all. Your PHP file replies in about 200 milliseconds, then the browser spends all it's time downloading the many assets needed to render the page.

You would need to take an alternative approach to the front-end of this page in order to improve it's performance. There are two things that I would suggest trying first:

# 1. One big problem is this JPG file, amongst others on the page: http://www.rovespier.com/user_profile_uploads/141979704492.jpg

This file is 1.1MB, which is massive for a web page. You never want to allow users to upload files of an unlimited size without resizing them. If you resized this file on upload to make it the size that you want it at (looks like it is used at a resolution of 102x102 pixels) the results would load much faster.

# 2. For the YouTube videos I suggest embedding a thumbnail for the video as a link, rather than the video itself. This will cause the page to load much faster as well.

You can generate thumbnails by loading these files, replacing [video-id] with the ID for the video:

http://img.youtube.com/vi/[video-id]/0.jpg
http://img.youtube.com/vi/[video-id]/1.jpg
http://img.youtube.com/vi/[video-id]/2.jpg
http://img.youtube.com/vi/[video-id]/3.jpg

More infor on thumbnails in the first answer to this question on SO.

Isaac_4 39 Junior Poster in Training

What is the URL to your page? The ISP's notes sound more related to a frontend (i.e. your browser can't load that many videos at once) than something you could solve in PHP, but it would be impossible for us to know without looking at the page as it loads.

Isaac_4 39 Junior Poster in Training

Be really careful when you use On DELETE CASCADE - if you do not set it up exactly correct you will end up removing records that you didn't intend to. As Bin_2 says, it would be better to post the schema of your tables and then we can tell you how to figure out what order you need to delete things in.

Basically, you need to find the table that has only outgoing references to other tables, delete the rows from that table, then move on to each table that it referenced in order until you find everything to remove.

For example, look at this schema:

                    ***********
                    * Contact *
                    * ID      *
                    * ClientID*
                    ***********
                         |n
                         |1
                    ***********
                    * Client  *
                    * ID      *
                    ***********
                         |1
                         |n
                    ***********
                    *Invoices *
                    *ID       *
                    *ClientID *
                    ***********

In this table structure, if you want to delete a particular Client record with ID = 5, you need to delete everything from Contact where ClientID = 5, then from Invoices where ClientID = 5, and finally from Client where ID = 5.

DELETE FROM Client WHERE ClientID = 5;
DELETE FROM Invoices WHERE ClientID = 5;
DELETE FROM Client WHERE ID = 5;

A foreign key cannot ever refer to a deleted record (well, not true if you don't use constraints, but you should pretend it is true anyway and never delete a record if there are references to it).

If you have recursive schema, like this for instance:

Isaac_4 39 Junior Poster in Training

Also, related to <unrelated> topic </unreleated> ;):

varchar(255) should be okay - char(255) would for sure be bad as it always takes up 255 characters. varchar on the other hand only takes what characters it needs, up to the limit you give it (no more than 255 characters in this case) although it is always a good idea to set lengths to realistic values so that users cannot mess up your system by putting in long values. So this is more of a usability issue for any admin screens than a true performance issue in this case.

You should also do things like strip_tags() on all your $_POST values for security reasons.

Isaac_4 39 Junior Poster in Training

I see, you are using the updated version of the functions from our comments on my thread. You need to add this line after including the file:

require_once("Mysqli.php");
$conn = db_connect(); // Make the connection

And it looks like in your latest version you are not actually calling the query, and the $tokens value isn't quite built correct, so adjust that part to be like this:

// Count comes from the number of items in the count($row) of the array,
// leave the '?' here as it is part of the PDO query
$tokens = array_fill('?', count($row));

$query = 'INSERT INTO requisition ( fdate, ref_no, from, copy, description, buyer, ref, potential_annual, target_price, market_app, instruct, comp_colour, pattern, sole_colour, calender_pattern, heel_type, heel_colour, moul_sole, top_fox, top_colour, bottom_fox, bottom_colour, last_type, boots_height, size, total_pairs, date_required, lin_material, cuff_material, lace_colour, brand, colour, lacquer_finishing, safety, features, attachment, remarks, department, pair, request_by, approval_status ) VALUES ('.implode(',', $tokens).')';

// Query should have a bunch of ? marks at the end of it
print $query;

// Actually run the query
$result = db_query($conn, $query);

if($result)
{
     echo "Requisition Successfully Added!";
}
else
{
    if(DEBUG) {
        echo "<b>MySQL error:</b><br/>";
        print_r($pdo->errorInfo());
    } else {
        echo "<b>Sorry, we could not process your request</b><br/>";
    }
}
Isaac_4 39 Junior Poster in Training

Some things to check...

Does your page now start with the line PHP Parsed okay? If not, there is something wrong with PHP's configuration or there is a syntax error in your file.

Did you put my db_query() function and the $pdo = new PDO(...); line into your dbcon.php file? If not, you need to either add it there or include the database.php file instead of dbcon.php. Make sure you also adjust the PDO() line to match your database settings.

Also, is the file this code in actually called form.php? This is where the form is trying to post to, so if youy renamed it, you need to change the <form> tag's action attribute to match the new filename.

Do you have a .htaccess file in the root of your site? You need to make sure your S/FTP program is set to show hidden files to see it, or if you are on the command line, us ls -al to show hidden files. If you do have such a file, try moving it (or delete it after making a backup locally, and checking the backup has the same contents as the original). It could be causing a redirect which may prevent the POST from working... which you can also check by looking in your browser's Developer Tools to see if after submitting the form you get any 301 or 302 or other interesting return codes.

To see if you can catch anything else, put an exit here at …

Isaac_4 39 Junior Poster in Training

What output do you get with my version? It should have printed out an error message object.

If you got no output at all, try putting this at the top of the file and report back what output you see:

<?php
echo "PHP Parsed okay<br/>";
ini_set('display_errors', 'on');
error_reporting(E_ALL);
Isaac_4 39 Junior Poster in Training

Diafol is very right, your code is subject to injection attachs. As hey says, you should at least call mysql_real_escape_string() on every value before putting them into your $sql variable. Even better would be to use my sample Safe and SIMPLE database inserts which should actually be even easier (less code) than what you are doing.

In your block where you print out that the SQL query failed, you can get more info by doing this:

echo "failed";
echo mysql_error();

Here is your insert query rewritten to use my include file, which is much safer to use than the raw mysql functions.

<?php

define('DEBUG', true);  // Change to false in production to prevent errors from showing to visitors!!

require_once("database.php");

// Get values from form
if(isset($_POST['submit']))
{
    $row = array(
        date('Y-m-d'),
        $_POST['ref_no'],
        $_POST['from'],
        $_POST['copy'],
        implode(',',$_POST['description']),
        $_POST['buyer'],
        $_POST['ref'],
        $_POST['potential_annual'],
        $_POST['target_price'],
        $_POST['market_app'],
        implode(',', $_POST['instruct']),
        $_POST['comp_colour'],
        implode(',', $_POST['pattern']),
        $_POST['sole_colour'],
        $_POST['calender_pattern'],
        $_POST['heel_type'],
        implode(',', $_POST['heel_colour']),
        $_POST['moul_sole'],
        $_POST['top_fox'],
        implode(',', $_POST['top_colour']),
        $_POST['bottom_fox'],
        implode(',',$_POST['bottom_colour']),
        $_POST['last_type'],
        $_POST['boots_height'],
        $_POST['size'],
        $_POST['total_pairs'],
        $_POST['date_required'],
        $_POST['lin_material'],
        implode(',', $_POST['cuff_material']),
        implode(',',$_POST['lace_colour']),
        $_POST['brand'],
        $_POST['colour'],
        implode(',', $_POST['lacquer_finishing']),
        implode(',', $_POST['safety']),
        implode(',', $_POST['features']),
        $_POST['attachment'],
        $_POST['remarks'],
        $_POST['department'],
        $_POST['pair'],
        $_POST['request_by'],
        'pending',
    );

    // Make N placeholders (the ? symbol is replaced by prepare with your value), where N == number of fields in the row to insert
    $tokens = array_fill('?', count($row));
    $query = 'INSERT INTO requisition ( fdate, ref_no, from, copy, description, buyer, ref, potential_annual, target_price, market_app, instruct, comp_colour, pattern, sole_colour, calender_pattern, heel_type, heel_colour, moul_sole, top_fox, top_colour, bottom_fox, bottom_colour, last_type, boots_height, size, total_pairs, date_required, lin_material, cuff_material, lace_colour, brand, colour, lacquer_finishing, …
Isaac_4 39 Junior Poster in Training

Did you check the Network tab and make sure that there are no 30_ or 40_ errors?

Isaac_4 39 Junior Poster in Training

You need to define what you want to redirect from as well as what you want to redirect to. Assuming that you want to go from:

http://example.com/test

to:

http://example.com/media.php?page=test

Then this should do the trick:

<IfModule mod_rewrite.c>
    # Turn on the engine
    RewriteEngine On

    # If your pages are under the root of the domain, leave as /
    # If they are instead under a subdirectory such as /test/,
    # change RewriteBase to be /test/
    RewriteBase /

    # Don't redirect real files (-f) or directories (-d)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # Do the redirect - if you had to change RewriteBase, add that
    # here as well - /test/media.php instead of /media.php
    RewriteRule ^(.*)$ /media.php?page=$1 [L]
</IfModule>

But if your situation is more complex, this won't cut it:

  • Do some URLs need to be redirected to files other than media.php?
  • Are there multiple base directories to redirect from (not just / or /test/ as in my comments, but more than one base)?
  • Do you need query strings to still work? (as is, in the URL http://example.com/test?q=1 the q=1 value will be stripped out and won't be visible to media.php)
Isaac_4 39 Junior Poster in Training

I suggest using DataTables to do this. Their zero configuration example does exactly what you want to an existing HTML table. It does also add search and a few things, so you may want to remove those extra features:

<!-- previous code the same -->
<table id="admintable" border="1" cellpadding="2" cellspacing="0">
<thead><!-- added -->
<tr>
    <th>Page</th><th>Post</th>
</tr>
</thead><!-- added -->
<tbody><!-- added -->
<?php
$i=0;
while ($data = mysql_fetch_array($result)){
$result2=($i%2)?'#DFA09D':'white';
        //echo "<tr bgcolor='$result2'>";                    
        //echo '<td>'.$data['page'].'</td>';
        //echo "<td><a href='post.php?post_id=".$data['post_ID']."'><img src='../images/post.jpg'></a></td>";
        //echo '</tr>';                  
        echo "<tr bgcolor='$result2'>";                  
        echo '<td><a href="input_berita_static.php?post_id='.$data['post_id'].'">'.$data['page'].'</a></td>';
        echo '<td>';
        if($data['post_type']=="post"){                                         
        echo '<a href="post.php?post_id='.$data['post_id'].'"><img src="../images/post.png"></a></td>';                                                 
        }
        echo '</tr>';
$i++;   
}
?>
</tbody>
</table><!-- added -->

<!---------------------- DataTables Begin ---------------------->
<!-- remove this line if you already have jquery -->
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>

<!-- include datatables library -->
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.3/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
    $('#admintable').DataTable({
        "paging": false,
        "searching": false
    });
});
</script>
<!---------------------- DataTables End ---------------------->

<!-- all other code the same -->

DataTables can also use server-side data loading so that it only fetches enough data to display at one time. This is not needed unless you have many thousands or millions of records, however, so the above should get you very far.

Note that you must have <thead> and <tbody> tags or DataTables will not load properly! Normally these tags are optional and many people don't even know they exist, but DataTables requires them.

Isaac_4 39 Junior Poster in Training

Those are not really errors - they are PHP code that isn't getting parsed. Somewhere you have a line that starts with "load->model(array('Mediatutorialaccount'))" which is not inside of a <?php block.

I would recommend searching the whole directory for the word "Mediatutorialaccount" to try to find where this is.

You will get a 404 if the URL you're trying to get to doesn't, by default, match controllerName/methodName. What URL are you trying to load?

Isaac_4 39 Junior Poster in Training

I believe you need to set CURLOPT_RETURNTRANSFER before CURLOPT_FILE:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FILE, $fp);
Isaac_4 39 Junior Poster in Training

Couple things:

  1. Use phpinfo() to make sure that the value is actually being changed or not. If your host runs PHP as FastCGI, you may need to kill the cgi processes.

  2. Your host may be killing the process using a different mechanism. This is common on many hosting providers such as HostGator, who kill processes that run longer than 5 minutes. Other hosts might have different rules, I wouldn't be surprised to see a process killed after 30 seconds on shared hosting.

Isaac_4 39 Junior Poster in Training

Yeah sorry about the errors, wasn't able to fully test the idea. Glad it helped though!

Isaac_4 39 Junior Poster in Training

Well it's actully returning some data. The three ... in bold mean that the output is being truncated because it's too deep. Try using print_r() instead of var_dump():

echo '<pre>';
print_r($obj);
echo '</pre>';

That should show you all the nested objects and arrays. You have to dig deeper into the returned data.

You probably have to do something like

foreach($obj->monitors->monitor as $monitor) {
    var_dump($monitor);
}
Isaac_4 39 Junior Poster in Training

Well without a valid API key the call returns an error object which does not have a datetime property.

Obviously you don't want to post your API key but can you post what object you do get from the last var_dump? It needs to actually have a datetime property or you will get an error (if errors are enabled) and $cc will remain unset.

Isaac_4 39 Junior Poster in Training

I recommend FPDF for this. Here is some sample code extracted from a project I did recently that filled out a complex employment application based on a web form. This won't quite run without adjustments but it should get you on the right track and includes a helper class to make printing text one method rather than two, and to allow for rotated text.

I've also attached a file that contains the lib/fpdf folder, including a functional font file (that was a bit tricky if I remember correctly).

<?php

require_once 'lib/fpdf/fpdf.php';
require_once 'lib/fpdf/fpdi.php';

class X_FPDI extends FPDI {
    var $angle=0;

    public function text($x, $y, $str) {
        $this->SetXY($x, $y);
        $this->Write(3, $str);
    }

    function RotatedText($x,$y,$txt,$angle)
    {
        //Text rotated around its origin
        $this->Rotate($angle,$x,$y);
        $this->Text($x,$y,$txt);
        $this->Rotate(0);
    }

    function Rotate($angle,$x=-1,$y=-1)
    {
        if($x==-1)
            $x=$this->x;
        if($y==-1)
            $y=$this->y;
        if($this->angle!=0)
            $this->_out('Q');
        $this->angle=$angle;
        if($angle!=0)
        {
            $angle*=M_PI/180;
            $c=cos($angle);
            $s=sin($angle);
            $cx=$x*$this->k;
            $cy=($this->h-$y)*$this->k;
            $this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
        }
    }

    function _endpage()
    {
        if($this->angle!=0)
        {
            $this->angle=0;
            $this->_out('Q');
        }
        parent::_endpage();
    }
}

$filename = APPPATH.'cache/entry_'.$entry->form_entry_id.'.pdf';
$source_filename = __DIR__.'/resources/employment_application_form.pdf';        // Template PDF to fill in

$pdf = new X_FPDI();
$pdf->AddPage();
$pdf->setSourceFile($source_filename); 
$pdf->AddFOnt('couriernewpsmt', '', 'couriernewpsmt.php');
$pdf->SetFont('couriernewpsmt');
$pdf->SetTextColor(0, 0, 0);
$pdf->SetLeftMargin(34);
$pdf->SetRightMargin(0);


/***** Cover *****/

$tplIdx = $pdf->importPage(1);  // Grab a page of the template
$pdf->useTemplate($tplIdx, -215, 0, 0, 0, true);      // Move the background over (two up pages in template)
// Comment out the above line and uncomment this line if the background is blank:
//$pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);

// $pdf->RotatedText(180, 60, …
Isaac_4 39 Junior Poster in Training

Some sample code. Post data to your customer's PHP file like this:

// Read data from DB
$query = $db->execute("SELECT * FROM `dlr_tbl` WHERE `fetched` = '0'");
$row = $query->getrows();

// Create an array of rows to encode, using the field names we want
$array_data = array();
for($i=0;$i<count($row);$i++) {
    $post_data[] = array(
        'extid' => $row[$i]['external_id'],
        'status' => $row[$i]['delivery_status'],
        'cause' => $row[$i]['cause'],
        'mobile' => $row[$i]['mobile_no'],
        'date' => $row[$i]['delivery_date'],
    );
}

// Encode data to a JSON packet
$json_data = json_encode($array_data);

echo 'DEBUG SEND: '.$json_data.'<hr/>'; // DEBUG only

// Post the JSON packet - no GET parameters needed, everything is
// in $json_data already
$furl = "http://www.example.com/library/getresponse.php";
$ch = curl_init($furl);
curl_setopt_array($ch, array(
    CURLOPT_URL => $furl,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $json_data
));
$curl_scraped_page = curl_exec($ch);
echo 'DEBUG RESULT: '.$curl_scraped_page; // DEBUG only
curl_close($ch);

Then in your customer's PHP file, getresponse.php, you can get the array back out like this:

// php://input returns all POST data. We want to decode it as JSON
$post_data = file_get_contents("php://input");
if($post_data) {
    if(substr($post_data, 1, 1) != '{') || substr($post_data, -1, 1) != '{')) exit('Error, POST data does not look like JSON');

    echo 'DEBUG RECV: '.$post_data.'<hr/>'; // DEBUG only
    $array_data = json_decode($post_data);
    var_dump($array_data); // DEBUG only
} else exit('Error, no data in POST!');
Isaac_4 39 Junior Poster in Training

Also all the data in the CURLOPT_POSTFIELDS will not be in the URL but rather part of the POST body, so don't worry about problems with URL length. gabrielcastillo's suggestion is a good way to do this.

Isaac_4 39 Junior Poster in Training

The problem is that the return result is not a valid JSON string:

jsonUptimeRobotApi({"stat": "fail","id":"100","message":"apiKey not mentioned or in a wrong format"})

This is, rather, a JavaScript function call. This type of "JSON" return is meant for consumption on the front-end of a website, inside the browser.

The easiest fix is probably to just parse out the JS function call with some string functions:

$api_key = "apikey here";
$server = "http://api.uptimerobot.com/getMonitors?apiKey=" . $api_key . "&logs=1&alertContacts=1&responseTimes=1&responseTimesAverage=180&format=json";
$server2 = file_get_contents($server);

if(substr($server2, 0, 19) == 'jsonUptimeRobotApi(' && substr($server2, -1, 1) == ')')
{
    $json = substr($server2, 19, strlen($server2) - 20);
    if(!is_null($json)) {
        $obj = json_decode($json);
        var_dump($obj);

        $cc =  $obj->datetime;// I assume that $alert was meant to be $obj
        echo $cc;
    }
}
Isaac_4 39 Junior Poster in Training

Good point! Maybe first two lines of database.php replaced with this new function would be a good idea:

function db_connect()
{
    // Connect to the database. This requires the PDO and PDO_Mysql modules to be installed in PHP.
    // TODO: Store this connection string in a config file instead of hardcoded
    return new PDO('mysql:host=localhost;dbname=database_name', 'username', 'password');
}

// Helper function to prepare and execute a statement with parameters immediately
function db_query($conn, $sql, $params=array()) {
    $query = $conn->prepare($sql);
    if($query->execute($params)) {
        return $query->fetchAll();
    } else {
        return array();
    }
}

Then usage looks like:

$conn = db_connect();
$result = db_query($conn, 'INSERT INTO posts(author, response_to, subject, post) VALUES(?, ?, ?, ?)', array(&$member_id, &$response_to, &$subject, &$post));

Otherwise a custom PDO could be made if the use case was more complex.

I usually use a framework (CodeIgniter has been my favorite but lately I've been using Mako and starting with Symfony2) -- but sometimes a simple script is better in my opinion. Hopefully some people get some miledge out of these!

Isaac_4 39 Junior Poster in Training

Here is a simple way to insert into a database that isn't much harder than using string concatenation - which we all know is very dangerous due to SQL injection attacks.

Put the code snippet into database.php.

Now, in a script handling a form post, such as post_reply.php:

<?php

require_once("database.php");

// Get session and post data to insert - no need for mysql_real_escape_string or other escaping
// (Note: Passwords should still go through password_hash() or crypt() though!)
$member_id = $_SESSION['member_id'];
$response_to = isset($_POST['response_to']) ? $_POST['response_to'] : (isset($_GET['response_to']) ? $_GET['response_to'] : '');
$subject = isset($_POST['subject']) ? $_POST['subject'] : '';
$post = isset($_POST['post']) ? $_POST['post'] : '';


// Use the db_query function from database.php with a parameter array to safely embed values into 
// the query without string subsitution. I seem to remember parameter binding doesn't quite work
// properly without the reference operator (&) on each variable in this array but can't test at
// the moment.
$result = db_query('INSERT INTO posts(author, response_to, subject, post) VALUES(?, ?, ?, ?)',
                        array(&$member_id, &$response_to, &$subject, &$post));

Even better of course would be to use a framework such as Laravel but for simple scripts this is very safe to use.

Isaac_4 39 Junior Poster in Training

Try adding these lines to the top of your PHP script to make sure errors show up:

define('DEBUG', true); // change true to false to disable errors showing up
if(DEBUG) {
  ini_set('display_errors', 1);
} else {
  ini_set('display_errors', 0);
}
error_reporting(E_ALL & ~E_NOTICE);

This might help you track down the error if the they are being hidden from you for some reason.

Also try to var_dump your variables to see if they have the values you expect. Combined and expanded with broj1's good recommendations this might look like this:

// sanitize the data - unless you use mysqli_prepare (mentioned again
// a few lines down) - NEVER access $_POST or $_GET without passing
// the value through mysqli_real_escape_string() or crypt() first.
// even if you do use mysqli_prepare, always use crypt() for passwords!
$username = mysqli_real_escape_string($_POST['username']);
// TODO: change second string ('*D') passed to crypt() to something unique to your
// site. if you have PHP 5.5 use password_hash instead of crypt.
$password1 = crypt($_POST['password1'], '*D'); 
//$password1 = password_hash($_POST['password1'], PASSWORD_DEFAULT);  // PHP 5.5 only
$email = mysqli_real_escape_string($_POST['email'])

echo "<br/>Username =";
var_dump($username);
echo "<br/>Password ="; // remember this will be a long string hash, that's good!
var_dump($password);
echo "<br/>Email =";
var_dump($email);

// prepare the query from sanitized data
// TODO/SECURITY RISK: instead of concatenating strings from user
// supplied values, you should consider using mysqli_prepare
// (see http://php.net/manual/en/mysqli.prepare.php) in which case
// mysqli_real_escape_string would no longer be required above
$sql = "INSERT INTO member (name, password, email) VALUES ('$name', …
broj1 commented: Nicely explained +11
Isaac_4 39 Junior Poster in Training

What do you mean by noise exactly?

Isaac_4 39 Junior Poster in Training

Open up your browser's JavaScript console. I bet the script manager is causing a syntax error or other error to occur which breaks the other JS on your page.

Isaac_4 39 Junior Poster in Training

This article has notes on the changes in 4.5.1. An example of something that could cause a problem - there do appear to be new datatypes. If you rely on those datatypes or the other changes this might actually matter a lot.

Isaac_4 39 Junior Poster in Training

Can you post your code?

Isaac_4 39 Junior Poster in Training

I recommend that you do indeed use MVC, it is (in my opinion) easiest to learn and superior as well.

I learned MVC 4 from these two books:

http://www.amazon.com/Professional-ASP-NET-MVC-Jon-Galloway/dp/111834846X/ - basics of MVC development

http://www.amazon.com/Microsoft-NET-Architecting-Applications-Enterprise/dp/073562609X/ - teaches good architecture which is useful even beyond .NET

One more book, which is a good general introduction if you have not done much C# at all. It is not specific to MVC or ASP.NET at all but rather about C# itself, which you should learn as a language apart from whatever framework you use:

http://www.amazon.com/Programmers-Edition-Deitel-Developer-Series/dp/0132618206/

Isaac_4 39 Junior Poster in Training

What version of xampp are you using?

Isaac_4 39 Junior Poster in Training

Unfortunately no, a finger print reader actually works by storing a cryptographic key in it's on board memory, then decoding a given value using that key ONLY if the finger print is CLOSE to the stored finger print. There is no way to transmit a fingerprint (or the cryptographic key itself) over the internet.

Isaac_4 39 Junior Poster in Training

Your Google SMTP account can send email to any address - if you are able to send email to yourself on Google without getting any warning bars at the top of the email view, it will work with any other email address as well. If you do get any of Google's yellow warning bars about the email not being from who it says it is from, or other errors. Post those and maybe we can help figure out what is wrong.

Isaac_4 39 Junior Poster in Training

Your pattern matches only a single character, add a + to match one or more characters:

if ( preg_match ('/^[a-z0-9]+$/', $username)) {
    echo $username. ' ' . $password . ' ' . $email;     
}
else {
    echo 'special characters are not allowed';
}

I suggest using a tool like RegexBuddy to help write and test regular expressions.

pritaeas commented: +1 for RegexBuddy +14
Isaac_4 39 Junior Poster in Training

You may want to move the file to a permanant location first using move_uploaded_file. The temp directory may have unusual permissions preventing you from reading the file, and these temp files are deleted very quickly as well. Without the rest of the context for your script it is hard to say if the file will still exist when you are running this.

Isaac_4 39 Junior Poster in Training

Scroll all the way up and click Edit profile in the top bar.

Isaac_4 39 Junior Poster in Training

Oops, replace that line with

<img src="<?php echo $item->getPrimaryImage()->getSource(); ?>" />

Really not sure if this all will work, I don't use Joomla specifically.

Isaac_4 39 Junior Poster in Training

This is likely because your user probably does not have the FILE privilege. I would be very much surprised to see a user on shared hosting that has this privilege as it's quite dangerous.

Note that phpMyAdmin has an export link at the bottom of all SQL results, just run your normal query, then download the file and upoad to wherever you need it.

Isaac_4 39 Junior Poster in Training

If you're looking for a rough ballpark of effort for something custom, from scratch, I'd say it's around 150-200 hours of work:

Homepage
Geographic search
Listing page
Detail page
Commenting / review functionality
Account management
Ad network integration

This excludes the mobile app which would add another 150-300 hours easily, unless it's nothing more than a shell around the mobile site (in which case I would not bother building it).

This includes front-end and back-end work but excludes actual design effort, which would be an additional cost at most places you'd go to get something done.

Isaac_4 39 Junior Poster in Training

It looks like you'll sort of have to rebuild that section a bit, something like this might work... Basically we're removing the image from the background of that first element (assuming this is the actual image you want) and moving it into a box that can have an anchor tag wrapped around it, if one is needed (if getPrimaryLink() returns true).

<style>
.custom-box {
    float: left;
    margin-right: 10px;
}
</style>
<li data-strips-item>
    <!-- removed image from background -->
   <div class="sprocket-strips-item" data-strips-content>
      <div class="sprocket-strips-content">
      <!-- added image as linkable img tag -->
         <?php if ($item->getPrimaryImage()) :?>
             <div class="custom-box">
             <?php if ($item->getPrimaryLink()) : ?><a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>"><?php endif; ?>
             <img src="style="<?php echo url(<?php $item->getPrimaryImage()->getSource(); ?>);" />
             <?php if ($item->getPrimaryLink()) : ?></a><?php endif; ?>
             </div>
         <?php endif; ?>
         <!-- end of changes -->
         <?php if ($item->getTitle()) : ?>
         <h4 class="sprocket-strips-title" data-strips-toggler>
            <?php if ($item->getPrimaryLink()) : ?><a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>"><?php endif; ?>
               <?php echo $item->getTitle();?>
            <?php if ($item->getPrimaryLink()) : ?></a><?php endif; ?>
         </h4>
         <?php endif; ?>
         <?php if ($item->getText()) :?>
            <span class="sprocket-strips-text">
               <?php echo $item->getText(); ?>
            </span>
         <?php endif; ?>
         <?php if ($item->getPrimaryLink()) : ?>
         <a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>
         <?php endif; ?>
      </div>
   </div>
</li>