cereal 1,524 Nearly a Senior Poster Featured Poster

@ardav
Sorry ^^! I opened the thread and went away.. didn't see you answer.. bye ;D


This should work, but maybe someone else can provide a better solution:

<?php
# database connection ...

$q = mysql_query("select category, count(category) as cat_total from images group by category");

while($row = mysql_fetch_object($q))
{
    echo "$row->category $row->cat_total";
}
?>

bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster
<?php
$brush_price = 5;
$quantity = 10;
$total = $brush_price * $quantity;
echo "<table border=\"1\" align=\"center\">
<tr><td>Quantity</td><td>Price</td></tr>
<tr><td>$quantity</td><td>$total</td></tr>";
?>

Bye.

Farhad.idrees commented: 1 +3
cereal 1,524 Nearly a Senior Poster Featured Poster

Just another version :P

<?php
$a = array('/st/','/nd/','/rd/','/th/');
echo preg_replace($a,'<sup>$0</sup>',date('dS F Y'));
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

Are you using a database or is just a directory?
If only a directory (images) and no database registration you can use glob():

<?php
# GLOB_NOSORT flag will help to go a bit faster
$a = glob('a_*.jpg',GLOB_NOSORT);
$b = glob('b_*.jpg',GLOB_NOSORT);

echo count($a) . " " . count($b);
?>

This can work by using a prefix for each category (like a_ and b_), but it can become slow if you start to have thousands of images. To limit reads on filesystem you can create a text file where you store a bidimensional array with categories and filenames, you can also store this information to memory with memcached. It's up to your needings.

edit: you can also consider scandir()* which is faster than glob() but available only with PHP5.

* http://php.net/manual/en/function.scandir.php

diafol commented: I like glob too :) +14
cereal 1,524 Nearly a Senior Poster Featured Poster

Add a loop:

$Families = array ( "Farhad" =>array("Ali","Haider","Kashan"), "Sufyan" => array("Shahbaz","Ali2","Azaan"));
 
foreach($Families as $key2=>$values3)
{
        foreach($values3 as $v)
        {
            echo "$key2 $v";
        {
}

bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

I think you need to use imagesavealpha(): http://php.net/manual/en/function.imagesavealpha.php
Place it just before imagepng(). Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

If you work in a chroot jail it is simple enough, configure and install apache and php, edit httpd.conf and php.ini and then just copy the jail where you want. Check this link for more information https://wiki.ubuntu.com/DebootstrapChroot

bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Do you have shift_id in both tables molding_section and intermediate_store? If yes, you need to change the where clause to: WHERE molding_section.shift_id='$shift_id' AND intermediate_store.shift_id='$shift_id'

cereal 1,524 Nearly a Senior Poster Featured Poster

Remove the asterisk, bye :)

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

Maybe I did not understand your question, can you paste the code?

cereal 1,524 Nearly a Senior Poster Featured Poster

You have to use switch() inside your index.php, an example:

<?php
$action = $_GET['action'];
switch($action) {
    case 'login':
    # code for login page
    break;
    case 'index':
    default:
    # code for home page
}
?>

http://php.net/manual/en/control-structures.switch.php

cereal 1,524 Nearly a Senior Poster Featured Poster

In report.php class, line 94 you echo inside the class but you should use return:

return $employee_id; #last id of multiple insert

In same function you should set a mysql_query() in order to insert. But it seems you want to send groups of arrays, reordered by report.php view, but there is something wrong, when you write:

$report->request_date[$i] = $_POST["request_date"];

you are not considering that multiple values are set under request_date (and also the others fields of the form), try to simply print_r() that variable: <?php print_r($_POST['request_date']); ?> and you will see an array with a value for each report form, so if there are three reports you will have three request_date values. At the moment you get six different arrays from your form and you need to create a single array, like in this example:

<html>
<head><title></title></head>
<body>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
        print_r($_POST['a']);
        echo "<br />";
        print_r($_POST['b']);

        $neworder = '';
        $c = count($_POST['a']);
        for($i = 0; $i < $c; $i++)
        {
                $neworder[] = array($_POST['a'][$i],$_POST['b'][$i]);
        }
        echo "<br /><pre>";
        print_r($neworder);
        echo "<pre>";
}
?>
<form method="post" action="">
a: <input type="text" name="a[]" />
b: <input type="text" name="b[]" />
<br />
a: <input type="text" name="a[]" />
b: <input type="text" name="b[]" />
<br />
<input type="submit" name="button" value="submit" />
</form>
</body>
</html>

The output:

Array ( [0] => a [1] => aa ) # first report
Array ( [0] => b [1] => bb ) # last report

# single array
Array
(
    [0] => Array
        (
            [0] => a
            [1] => b …
socialmd commented: Informative, shed light on flaw in code, and explained process very well +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Which one are you using? There are different kinds of nosql databases.. bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

You have already asked this question here:

http://www.daniweb.com/web-development/php/threads/407319

cereal 1,524 Nearly a Senior Poster Featured Poster

The principle is the same of placing a watermark, just set coordinates and the text you want to place into an existing image. Here is an example, you can try it with the image attached:

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$im = new Imagick('example.png');
$draw = new ImagickDraw();
$draw->setFontSize(18);
$draw->setFont('Arial');
$draw->setFillColor('#cc3300');
$im->annotateImage($draw, 25, 23, 0, $ip);

header( "Content-Type: image/{$im->getImageFormat()}" );
echo $im;
?>

Then you can:

1. save image and cache
2. or you can add to .htaccess file a directive so you can execute PNG as PHP and rename your test.php file to test.png, but this should be restricted to a directory:

<Directory /var/www/website/test/>
Options -Indexes
AddType application/x-httpd-php .png
</Directory>

so instead of: http://localhost/test/test.php
you can write: http://localhost/test/test.png

More info:
- http://php.net/manual/en/imagick.annotateimage.php
- http://php.net/manual/en/security.hiding.php
- http://httpd.apache.org/docs/2.0/mod/core.html#directory

bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

This will display user IP:

<?php echo $_SERVER['REMOTE_ADDR']; ?>

Then use GD library or imagemagick to create an image from that text, for example with imagemagick from command line it will be:

<?php
$ip = $_SERVER['REMOTE_ADDR'];
exec("convert -pointsize 30 -label '$ip' image.gif");
?>

Anyway a section for .htaccess is in Hardware & Software » Linux & Unix » Linux Server & Apache. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Change addslashes() with mysql_real_escape_string() at line 16.
But you should also move file somewhere else with move_uploaded_file() and check for mime-type match. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

You are welcome, bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Why all those quotes? Rewrite your statements:

if($_POST['type_id'] == FALSE && $_POST['location_id'] > 0 && $_POST['bedroom_id'] > 0 && $_POST['price_id'] > 0)
manc1976 commented: Thanks for showing me a better way to write this code +1
cereal 1,524 Nearly a Senior Poster Featured Poster

Why don't you set a random password and send that to the user via email? That way the user will change it after he logs to his own profile.

cereal 1,524 Nearly a Senior Poster Featured Poster

The query is wrong, you wrote:

mysql_query("insert into exp values('$org','$des','$stat','$duty','$from','$to')");

But the database table does not know in which order and which fields you are requesting to be written, so change your code with this, or similar adapting to your database table:

mysql_query("insert into exp ('org','des','stat','duty','from','to') values('$org','$des','$stat','$duty','$from','$to')");

bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

you're welcome, bye! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

^^ I tried media, thumbnail, media:thumbnail and every other possibility already lol. didn't work and that's why I asked again

use my code posted above, without changing anything, is tested and works, in this case you don't have to set a namespace because we are using getElementsByTagNameNS() which needs just the namespace URI for media, which, in your case, is http://search.yahoo.com/mrss/

So, for completeness:

<?php
$xml="http://feeds.bbci.co.uk/news/rss.xml";
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$i = $xmlDoc->getElementsByTagNameNS('http://search.yahoo.com/mrss/','thumbnail');
echo $i->item(0)->getAttribute('url');
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

Yes:

<input type="radio" name="button1" value="On" onClick="submit();" <?php echo ($_POST['button1'] == 'On') ? 'checked="checked"' : ''; ?> /> On
	<input type="radio" name="button1" value="Off" onClick="submit();" <?php echo ($_POST['button1'] == 'Off') ? 'checked="checked"' : ''; ?> /> Off

bye!

Xufyan commented: thanku xufyan +3
cereal 1,524 Nearly a Senior Poster Featured Poster

Set the same name attribute to both input:

<input type="radio" name="button1" value="on" /> on
<input type="radio" name="button1" value="off" /> off

And in PHP side check for $_POST value, bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

Almost there, you don't need create function but getElementsByTagNameNS(): http://www.php.net/manual/en/domdocument.getelementsbytagnamens.php

$i = $xmlDoc->getElementsByTagNameNS('http://search.yahoo.com/mrss/"','thumbnail');
echo $i->item(0)->getAttribute('url');

bye :)

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

Sorry for delay, I forgot to reply, just add $dom->save('books.xml'); at the end of your code and it will work, if you have write permission in the folder. Bye :)

p.s. just remember to replace book, title, author & publisher with buku, etc.

cereal 1,524 Nearly a Senior Poster Featured Poster

This is not hacking but vandalism by some people who define themselves hackers and have fun doing these kind of messes.. read here: http://en.wikipedia.org/wiki/Website_defacement

You may need to check the code of your website and filter any input received by GET and POST forms and links. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

So it seems, I've tried this and hello is not printed:

<?php
echo <<<HTML
test 1
<?php echo 'hello'; ?>
test 2
HTML;
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

On last file try to move session_start(); at very top of the file. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

It seems ok but I don't see the form, so check if there is something different between field names and $_POST vars. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

You need ffmpeg and ffmpeg-php extension which works only on linux and bsd, read here:

http://ffmpeg.org/faq.html#How-do-I-encode-single-pictures-into-movies_003f
http://sourceforge.net/projects/ffmpeg-php/

bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

check here: http://www.php.net/manual/en/
there you can learn basics of PHP, search also for some tutorials, on google you can find tons of links, bye! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

profpic is the image name or the image itself? What kind of column is profpic: blob or varchar?

cereal 1,524 Nearly a Senior Poster Featured Poster

Just a note, you can go a bit faster changing numbers with variables, a modified version of mikulucky:

<?php
$a = 0;
$b = 1;
$c = 2;
$d = 3;
$endAmount = 100000;

for ($i = $a; $i <= $endAmount; $i++) 
{

    if($i % $c != $b) 
    {
      continue;
    }

    $x = sqrt($i);

    while ($i % $d != $a && $d < $x)
    {
        $d += $b; 
    }

    if((($i % $d == $a && $i != $d) * $b) == $a) 
    {
	echo $i . " ";
    }
 }
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

With SimpleXML, as in the examples page ( http://www.php.net/manual/en/simplexml.examples-basic.php ) you can do:

<?php
$file = file_get_contents('books.xml');
$books = new SimpleXMLElement($file);

foreach($books as $book)
{
        # echo buku attribute
	echo $book['isbn'];

        # echo childs
	echo $book->judul;
	echo $book->pengarang;
	echo $book->penerbit;
}
?>

bye :)

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

You write book but in your xml the correspondent is buku, so change all them to match your xml:

$books = $doc->getElementsByTagName( "buku" );

Also consider to use SimpleXML: http://php.net/manual/en/book.simplexml.php
bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

happy new year! :)

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

I can't really help you but I was reading here: http://www.mathworks.it/products/new_products/webserver_discontinued.html
Maybe you can use COM functions: http://uk.php.net/manual/en/ref.com.php

bye and happy new year! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Which query, there are so many? o_o' Have you tried to run your queries directly in MySQL shell or via PHPMyAdmin?

cereal 1,524 Nearly a Senior Poster Featured Poster

Check these links: http://phpxmlrpc.sourceforge.net/doc-1.1/ch05s02.html & http://phpxmlrpc.sourceforge.net/doc-2/ch07s02.html (updated version)

The constructor takes the following form:

$msg=new xmlrpcmsg( $methodName,
$parameterArray);
$methodName;
$parameterArray;
Where methodName is a string indicating the name of the method you wish to invoke, and parameterArray is a simple Array of xmlrpcval objects.

where $methodName is 'execute' in your example. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

I'm using php and mysql.

Sorry, but you are posting just javascript code. This is PHP forum, we can help you on PHP part. And in order to add something, if you want to use javascript, you need AJAX poiting to a PHP script which adds your input to your database. Otherwise just use a simple form. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

From substr() manual:

string substr ( string $string , int $start [, int $length ] )
If length is given and is 0, FALSE or NULL an empty string will be returned.

The problem is related to substr() on line 6, because strrpos() returns FALSE when there are no spaces:

$string = substr($string, 0, strrpos($string, ' '));

therefore you have substr('nospacestring',0,false) In order to solve change that line with this, which makes use of ctype_space():

if(ctype_space($string))
{
   $string = substr($string, 0, strrpos($string, ' '));
}

bye :)

dean8710 commented: tq dude +2
cereal 1,524 Nearly a Senior Poster Featured Poster

Set the charset meta tag to match server encoding. You need to set this value both in sending and in receiving page. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

How these file are uploaded to server? FTP, WebDav, forms?
How you have to send the files? As attachments or as download links? Second option, if you can, is preferable.

Basically anyway, if you want to submit by forms, you have to build a proper form to upload files, use the relative array $_FILES to check, rename and move them to a directory (throught move_uploaded_file()) and finally use mail() or PEAR mail() which is better for long running loops:

- http://php.net/manual/en/reserved.variables.files.php
- http://php.net/manual/en/function.move-uploaded-file.php
- http://php.net/manual/en/function.mail.php
- http://pear.php.net/package/Mail/

Both procedures: upload and mail attachments, have been discussed in the forum.
If the email list is fixed I suggest you to build an array and use that instead of a database connection, so you can speed up and limit hits on database.

cereal 1,524 Nearly a Senior Poster Featured Poster

If you check the headers of that link you will see that first time you download the file you get:

HTTP/1.1 200 OK
Content-Type: text/html; charset=ISO-8859-1
Date: Tue, 20 Dec 2011 23:15:55 GMT
Expires: Tue, 20 Dec 2011 23:16:55 GMT
Transfer-Encoding: chunked
Connection: Keep-Alive
Set-Cookie: JSESSION_ID_hrly_data=G1zpTxXLBnKKK3jqXh0vpkJzh8VtkVcq1jPrjDNKtrcJ5kwv8nSm!1260773349; domain=.iso-ne.com; path=/; HttpOnly
Set-Cookie: markets_hrly_data_lb=ROUTE.markets_hrly_data0; path=/markets/hrly_data;
Last-Modified: Tue, 20 Dec 2011 23:15:54 GMT
X-Powered-By: Servlet/2.5 JSP/2.1

Right after:

HTTP/1.1 200 OK # this is probably 304, my DNS returns 200
Content-Type: text/html; charset=ISO-8859-1
Date: Tue, 20 Dec 2011 23:16:03 GMT
Expires: Tue, 20 Dec 2011 23:16:55 GMT
Transfer-Encoding: chunked
ETag: W/"-1-1324422955000"
Connection: Keep-Alive
Set-Cookie: markets_hrly_data_lb=ROUTE.markets_hrly_data0; path=/markets/hrly_data;
Last-Modified: Tue, 20 Dec 2011 23:15:55 GMT
X-Powered-By: Servlet/2.5 JSP/2.1

What we see in both response headers is the expiration time, set to 1 minute after first download, for each subsequent request in the minute right after, you will get always the same data, most of the times. Is not only the Date to state this, but also ETag used to compare cached version with server response.

You can try to alter ETag in your request and see what you get, I tried and I get HTTP/1.0 303 See Other from OpenDNS which is caching, so try it by your self:

curl -I -H "ETag: W/-1-1324425159000" http://www.iso-ne.com/markets/hrly_data/selectHourlyLMP.do?locationType=HUB&node=4000&startDate=12%2F20%2F2011&endDate=12%2F20%2F2011

Anyway, if you don't get any fresh result you can set your script to check ETag, in this case his value between -1- and 000 is the unixstamp of when the cached resource is created, which is always …