cereal 1,524 Nearly a Senior Poster Featured Poster

No, you wrote $count; outside the loop, this can generate an error, change it with $count = 0; and inside the loop place $count++; just as in my previous example, if you do this it will start to work in the correct way.

Quick example:

<?php
$count = 0;
$a = array('a','b','c','d');
foreach($a as $b)
{
    $count++;
    echo 'fotog'.$count;
}
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

You need $count = 0; before the loop and $count++; inside the loop, as in my example.

Is this a Javascript limitation?

no, this is an HTML directive*

This attribute (ID) assigns a name to an element. This name must be unique in a document.

if you use the same ID multiple times, you will break the DOM reference.

*source: http://www.w3.org/TR/html401/struct/global.html#h-7.5.2

cereal 1,524 Nearly a Senior Poster Featured Poster

Old ok, sorry to bring this up but check dmoz.org you won't find "best" categories but you can find human-edited directories. I was a volunteer years ago, they usually accept to publish only what can bring a value to the directory, so this may be a place to start.

http://www.dmoz.org/help/geninfo.html

;D

cereal 1,524 Nearly a Senior Poster Featured Poster

It could be the ID (fotop & fotog) in your tags: your javascript is searching for an ID, but each ID this must be unique, if your pages loops ten times, you will have 10 fotop and 10 fotog ID and this is wrong.

Change your script to add numbers at the end of each ID, an example:

<?php
$count = 0;
foreach($_options as $option)
{
    $count++;

    echo '<img id="fotop'.$count.'" name="fotop'.$count.'" height="100px" width="100px" src="">';

    echo '<dd><img id="fotog'.$count.'" name="fotop'.$count.'" src=""></img>'. Si.'</dd>';

    # javascript
    echo '
    document.getElementById("fotop'.$count.'").src=hero;
    document.getElementById("fotog'.$count.'").src=hero;
    ';
}
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

I dont' think there is a limit: http://www.php.net/manual/en/language.types.array.php
but consider: an array can contain strings and/or ints, a string max lenght is ~2GB, the int limit is platform dependent, default is two billions.

So the array will probably be limited by the memory_limit in php.ini or by the amount of RAM.

string: http://www.php.net/manual/en/language.types.string.php
int: http://php.net/manual/en/language.types.integer.php

cereal 1,524 Nearly a Senior Poster Featured Poster

@mschroeder that's a great suggestion!

cereal 1,524 Nearly a Senior Poster Featured Poster

I usually use text editors like gedit, jEdit (which is cross-platform and my choice in Windows environments) and nano when working without a gui.

cereal 1,524 Nearly a Senior Poster Featured Poster

I started in '87 with Atari Basic, I was little and, at that time, it was just something fun to do, I liked to try changing little list of codes I had. After that I attended my first "programming" class, in which I learned GWBasic, it was '91/'92 I think. Just fun.

One of the greatest training experiences about programming and general computer know-how, for me, were the lectures done by the BSRF (BlackSun Research Facility) group in IRC around 2000/2002. Now, that group does not exists anymore, but it is there that I realized my passion for programming.

cereal 1,524 Nearly a Senior Poster Featured Poster

No problem, change $_GET['userid'] to $_POST['userid'] and it should work. As in my previous post (I edited that post changing $_GET with $_POST after I checked your previous script).

cereal 1,524 Nearly a Senior Poster Featured Poster

condition = 'value' is just an example, you have to choose your condition for the WHERE statement, for example, basing on your table write: userid = '$_POST[id]'

cereal 1,524 Nearly a Senior Poster Featured Poster

Remove those parentheses after userid = and before WHERE.

cereal 1,524 Nearly a Senior Poster Featured Poster

$_FILES[] is a superglobal variable: http://php.net/manual/en/reserved.variables.files.php

You can read the Language Reference section in the PHP Manual to get the information you are searching for: http://www.php.net/manual/en/langref.php

cereal 1,524 Nearly a Senior Poster Featured Poster

You UPDATE query is wrong, you wrote:

UPDATE table SET() WHERE VALUES();

Change it to:

UPDATE users
SET userid = '$_POST[userid]',
firstname = '$_POST[firstname]',
lastname = '$_POST[lastname]',
email = '$_POST[email]',
username = '$_POST[username]',
password = '$_POST[password]',
role = '$_POST[role]')
WHERE condition = 'value';

Check this for more info: http://dev.mysql.com/doc/refman/5.5/en/update.html
And remember to sanitize data.

cereal 1,524 Nearly a Senior Poster Featured Poster

$query = ("DELETE FROM users WHERE fieldname = '".$_GET["userid"]."' LIMIT 1");

Change fieldname to userid, bye! ;D

cereal 1,524 Nearly a Senior Poster Featured Poster

Leave enchant.dll in the c:\php\extensions directory and move the others to the parent: c:\php or to c:\php\dlls and restart the server as explained here:

Some of the extensions need extra DLLs to work. Couple of them can be found in the distribution package, in the C:\php\dlls\ folder in PHP 4 or in the main folder in PHP 5, but some, for example Oracle (php_oci8.dll) require DLLs which are not bundled with the distribution package. If you are installing PHP 4, copy the bundled DLLs from C:\php\dlls folder to the main C:\php folder. Don't forget to include C:\php in the system PATH (this process is explained in a separate FAQ entry).

source: http://php.net/manual/en/install.windows.extensions.php

And if you read the FAQ entry http://www.php.net/manual/en/faq.installation.php#faq.installation.addtopath
you will read how to add the path c:\php otherwise the system will not find the additional dlls.

About your script

Checking a string can be slow. In your code you are doing two queries for each word, you can speed the queries by creating an index and searching an hash in the first query. You will need to add a varchar field to your table:

ALTER TABLE unicode ADD word_hash varchar(32) NOT NULL;

and run a query to update the table, this will add the hash value to word_hash field:

UPDATE unicode SET word_hash = (SELECT MD5(word));

and create an index containing the word_hash, the word and the id (if present):

CREATE INDEX word_index on unicode (word_hash,word,id);

then you …

cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Try substr(): http://www.php.net/manual/en/function.substr.php

$a = 1234;
echo substr($a,-1,1); # outputs 4
cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, that means the extension is not loaded, try to restart Windows and if it does not work, please explain what you have done, maybe the dll is in the wrong directory..

cereal 1,524 Nearly a Senior Poster Featured Poster

I need information in order to help you. What you get if you run:

<?php
echo extension_loaded('enchant') ? 'working':'not loaded';
?>

And which platform/PHP version are you using?

cereal 1,524 Nearly a Senior Poster Featured Poster

Which platform and which PHP version are you using? On debian/ubuntu, for example, you need to write sudo apt-get install php5-enchant (this will probably reload Apache). For Windows follow these instrunctions:

http://php.net/manual/en/install.windows.extensions.php
http://www.php.net/manual/en/install.pecl.windows.php

At the end: you just need to download the extension, place the dll in the extensions directory of PHP, edit the configuration file to set the new extension and reload/restart Apache or the extension will not be loaded.

NOTE: at the moment, in Windows, you should compile the extension on your own because the pecl4win.php.net is still not available, but you can use those provided by the team: http://downloads.php.net/pierre/ just follow the instructions in the downloaded package.

Reference: http://stackoverflow.com/questions/2048309/pecl-extesions-for-windows

cereal 1,524 Nearly a Senior Poster Featured Poster

You need to provide a viewer, just like Google Docs or Scribd does. And I think you will need to convert them to PDF format and from that to SWF, there is an open source project for PDF: flexpaper, just search it, bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, you need a PWL file: a PWL file is personal word file one word per line, if you have words in the database just loop them into a file. And you have to use the function enchant_broker_request_pwl_dict() like this:

<?php
$r = enchant_broker_init();

# PWL dictionary path/file
$mydict = 'dict.pwl';

# word to check
$word = 'swrd';

# load custom dictionary
$d = enchant_broker_request_pwl_dict($r,$mydict);

# load standard dictionary instead of a custom
//$d = enchant_broker_request_dict($r,'en_GB');

$dict_details = enchant_dict_describe($d);
$dprovides = enchant_dict_describe($d);
echo "dictionary provides:\n";

$wordcorrect = enchant_dict_check($d, $word);

# details about the loaded dictionary
print_r($dprovides);

if (!$wordcorrect) {
    $suggestions = enchant_dict_suggest($d, $word);
    $result = array();
    foreach ($suggestions as $suggestion) {
        similar_text($word, $suggestion, $percent);
        if (round($percent) > 80) {
            $result[] = $suggestion;
        }
    }
}

# no duplicates, with Enchant I think this can be removed
$result = array_unique($result);
print_r($result);

enchant_broker_free_dict($d);
?>

Read here for more info:
* http://www.php.net/manual/en/enchant.installation.php
* http://www.php.net/manual/en/function.enchant-broker-request-pwl-dict.php

cereal 1,524 Nearly a Senior Poster Featured Poster

That's true in Windows platforms, it's supported until PHP 4.3.3, but in Linux it works also with newer versions. In substitution you can use Enchant: http://www.php.net/manual/en/intro.enchant.php

You can create a script similar to my previous, just check the example in the enchant_dict_suggest(): http://www.php.net/manual/en/function.enchant-dict-suggest.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Glad you solved :)

And in terms of the or die(mysql_error()); don't I need it as I am saying to kill the script if it fails and to display a piece of text. In this case the mysql error?

You can use mysql_error() if you have a query in that same script, but usually you set this right after a query, not in the echo. As you did for mysql_connect() and mysql_select_db(). Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

I think your first script is ok but, you can check by placing print_r($_POST); exit; right after session_start() and see what you get from your form.

Then, in your second script you have the curly brackets without any condition and or die(mysql_error()); but I don't see any query. Try to remove them.

cereal 1,524 Nearly a Senior Poster Featured Poster

What kind of application are you trying to use?

If for example it's a converter: you submit a file, PHP will run the exe tool and output the result to the client. You won't get an interface.

cereal 1,524 Nearly a Senior Poster Featured Poster

If the tables structeres are the same then you can use UNION, something like:

SELECT * FROM table1 WHERE condition = 'this' UNION SELECT * FROM table2 WHERE condition = 'this';

But if the tables are the same you will get a better performance if you merge them in a single table and create an index. http://dev.mysql.com/doc/refman/5.0/en/union.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes if this exe can be executed from command line and if the server platform is Windows, otherwise, if for example is Linux, you need to add Wine or VMWare to your server installation.

In a Windows platform, you can also use COM to deal with programs like Outlook, Word... http://www.php.net/manual/en/intro.com.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Check you code at line ~16 and if you don't find anything strange then paste your script here.

@vibhaJ sorry, I didn't saw your answer! ;D

cereal 1,524 Nearly a Senior Poster Featured Poster

There is a vulnerability in certain CGI-based setups (Apache+mod_php and nginx+php-fpm are not affected) that has gone unnoticed for at least 8 years...

read more: http://www.php.net/archive/2012.php#id2012-05-03-1

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

What do you get if you echo $userfile[0] and $userfile[1]? Here I don't see how those variables are set.
Also remove @ from mysql_query and add or die(mysql_error()); at the end, so you can see what is wrong with your query.

cereal 1,524 Nearly a Senior Poster Featured Poster

Here in Italy is high: 9.50$ (in euro 7.17€) per gallon.. ~1.895€ per liter but in some places we arrive to 2€ per liter... this happens because almost 60% of the final price is composed by government taxes and vat..

cereal 1,524 Nearly a Senior Poster Featured Poster

You can check for the PID with getmypid(): http://php.net/manual/en/function.getmypid.php
Or you can use beanstalkd or gearman, these are job servers for scripts: you register a worker, essentially this means that you start a script with a never ending loop that waits to get a work from the job server.

When a client sends a work to the job server this checks if the worker is available and sends the job, if not then it waits until the worker can perform the job. You can register more than one worker (hundreds if you need it) for each task and let the server work. Between beanstalkd and gearman I prefer the second because there is also persistence: job queue can be stored to a MySQL database, so if you restart the job server nothing gets lost.

http://php.net/manual/en/book.gearman.php & http://gearman.org/

https://github.com/kr/beanstalkd

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Also, you can use $this->input->post('fieldname'); instead of $_POST['fieldname'] and you can just write: $this->books->save_books();

http://codeigniter.com/user_guide/libraries/input.html

cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome, if your problem is solved please mark the thread as solved, bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Virtually there is no limit, the session file will be stored in a server directory or into a database (if you configure it). But you have to check memory_limit in php.ini because the script will stop if you get over:

http://www.php.net/manual/en/ini.core.php#ini.memory-limit

cereal 1,524 Nearly a Senior Poster Featured Poster

A great article about this topic, in my opinion, is this: http://www.componentowl.com/blog/2012/02/zen-coder-vs-distraction-junkie/

I'm usually the cause, the "distractor-junkie" of the situation... but when I work on something interesting for me, then I can stay on that for hours without noticing anything else.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can do it like this:

<?php

$word = 'swrd';
$pspell_config = pspell_config_create("en");

# Available modes:
#
# PSPELL_FAST
# PSPELL_NORMAL
# PSPELL_BAD_SPELLERS
#
pspell_config_mode($pspell_config, PSPELL_BAD_SPELLERS);
$pspell_link = pspell_new_config($pspell_config);

$result = array();
if (!pspell_check($pspell_link, $word)) {
    $suggestions = pspell_suggest($pspell_link, $word);

    foreach ($suggestions as $suggestion) {

        similar_text($word, $suggestion, $percent);
        if (round($percent) > 70) {
        $result[] = $suggestion;
        }
    }
}
$result = array_unique($result); # no duplicates
print_r($result);
?>

In this example at 70 you get:

Array
(
    [0] => surd
    [1] => sward
    [2] => sword
    [3] => seaward
    [4] => sward's
    [5] => swards
    [6] => sword's
    [7] => swords
    [8] => ward
    [9] => word
)

At 80 just:

Array
(
    [0] => sward
    [1] => sword
)

Hope is useful, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Have you tried pspell? http://www.php.net/manual/en/book.pspell.php
For precision, you can use pspell_suggest(): http://www.php.net/manual/en/function.pspell-suggest.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Each MySQL server can handle more than one database, so you can have 200 databases in the same computer, if so then you need just a connection to this server and run your queries as in the script above.

Besides previous suggestions: if your databases are located in different remote locations then you can create a page/file, in each server, which displays query results via web, you can use a function like json_encode() or serialize() to create a portable array:

<?php
# remote server: remote.dba1
# ... connection to database ...

$q = mysql_query("select * from table limit 0,30");
$a = array();
while($r = mysql_fetch_object($q))
{
    $a[] = array(
        'city' => $r->city,
        'something' => $r->something,
        'something_else' => $r->something_else
        );
}
echo json_encode($a);
?>

Then in your main server you can get data with a function like file_get_contents() and use json_decode/unserialize to get back an array:

<?php
# main
$dba1 = json_decode(file_get_contents('http://remote.dba1/page'));
print_r($dba1);
?>

You will need a loop here for each server. You can also use gz to reduce data transfer and igbinary_serialize which is faster than json and serialize. But you can also use curl or ftp functions instead of file_get_contents() so you do not expose remote data.. there are many possible solutions. Hope it's clear, English is not my main language.. bye! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Something is not clear to me: your databases are all in the same server? If yes then this kind of select can be done, but you need to perform only one connection to a MySQL SERVER, actually it seems you are going to connect 100 different remote servers but your first while loop is going to overwrite those connection variables and at the end of the loop, you have only one value for each variable, the last one. So can you perform only one connection. Also in order to query all databases you need to change this a bit:

<?php

$sql= 'select * from city ORDER BY id DESC';
$result=mysql_query($sql);
$counter=mysql_num_rows($result);
$i=1;
$all="";
while($rows = mysql_fetch_array($result)){
    $city =$rows['city'];
    $state=$rows['state'];
    $citytrimmed = str_replace(' ','',$city);
    $statetrimmed = str_replace(' ','',$state); 
    $cityst= strotolower($citytrimmed . $statetrimmed);
    $all.= 'SELECT * FROM '.$cityst.'.Sports';

    if($i < $counter){
        $all.= ' UNION ALL ';
        $i=$i+1;
    }else{
        $all.= ' ORDER BY timestamp DESC LIMIT 100';
    }

}

$citydbhost = 'localhost';
$citydbuser = 'user_allowed_to_access_and_select_from_all_db_involved';
$citydbpass = 'XXXXXX';

include 'cityopendb.php';
$query=mysql_query($all) or die(mysql_error());
while($row=mysql_fetch_array($query)){

}

?>

Otherwise you need to loop through each database, select, save result to an array and merge it with other results, or you need to use Federated tables or you need to change the configuration of your servers, read this answer: http://stackoverflow.com/a/508114/963510

cereal 1,524 Nearly a Senior Poster Featured Poster

Why don't you use an enum field, something like:

alter table opentix add completed enum('y','n') default 'n' not null;

from this point when you want to check open tickets just use select * from opentix where completed = 'n' or similar.. anyway to make it work you need to set the rows, change your query to this:

INSERT INTO $tbl_name2 ($tbl_name2.field_1,$tbl_name2.field_2) SELECT $tbl_name.field_1,$tbl_name.field_2 FROM $tbl_name WHERE tixnum='$del_id'

cereal 1,524 Nearly a Senior Poster Featured Poster

Sorry for the additional comment but I forgot to add this to my previous reply: you can also check and increase the size of the buffer for the index instead of the sort buffer:

cereal 1,524 Nearly a Senior Poster Featured Poster

I don't know if you solved, but what you get if you run show indexes from articles; this will give you some values for each field in the index, check about cardinality, if this is too low in some fields, for example in forumid, deleted and lastpost then this can be the reason why the index is not working: too many rows to read. And if this happens the reading buffer can't read all rows and use filesort() to read small part of data, check: http://s.petrunia.net/blog/?p=24

So maybe you can try to increase sort_buffer_size (default is ~2MB) and let fit the index in memory: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_sort_buffer_size

cereal 1,524 Nearly a Senior Poster Featured Poster

Between line 11-13 there is no echo and on line 15 you are not escaping double quotes as in the other tags. Change it to:

<img src=\"http://www.lisa1986.com/images/mainLogo.png\">
cereal 1,524 Nearly a Senior Poster Featured Poster

Change this: implode(", ", $new) to single quotes: implode(', ', $new) bye!

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

You could use Gearman: http://gearman.org/#introduction
Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use dompdf: http://code.google.com/p/dompdf/
Bye!