johny_d 23 Junior Poster in Training

You can test for all the three patterns at once with this

if (preg_match('/^([0-9]{2}\.\*|[0-9]{2}\.[0-9]{4}\.\*|[0-9]{2}\.[0-9]{4}\.[0-9]{2})$/', $article)) {
   // match
}
else {
   // no match
}

The '.' (dot) and the "*" are special characters in regular expressions, so if you want to match those characters you have to escape them (put a "\" - backslash - before each special character you want to escape)

johny_d 23 Junior Poster in Training

Yes, that is the LEFT JOIN: it returns all the records from the first table that match the conditions of the query, joined with the coresponding rows from the other table(s) if there are any or with NULL values instead where there are no coresponding rows.

johny_d 23 Junior Poster in Training

Your regex pattern has two problems:
1. it has * as the character counter, which means "0 or any number of charcaters frm the class".
This means that a string containing even none (0) of your characters will match your expression
2. you didn't specify that there cannot be other characters before and after the pattern
Here is how it should be:

$ids_list = '112,5,16,4578';
 
if (preg_match('/^[0-9,]+$/', $ids_list))
  echo'OK!';
else
  echo'KO!';

The "+" sign after the character class says there should be at least 1 character from there
The ^ at the beginning and $ at the end say you cannot have other characters before and after the string matching your pattern.
However, this solution will also match "," - a single comma string.
Maybe a better one would be

$ids_list = '112,5,16,4578';
 
if (preg_match('/^[0-9]+(,[0-9]+)*$/', $ids_list))
  echo'OK!';
else
  echo'KO!';

This matches a string containing a group of 1 or more digits, followed by 0 or more groups of a comma followed by some digits
;)

johny_d 23 Junior Poster in Training

Can you post here the part of the script before this loop? Especially the query part!

johny_d 23 Junior Poster in Training

try mysql_fetch_assoc instead of mysql_fetch_array

johny_d 23 Junior Poster in Training

If this si what you want - to have all the attribute values in a comma separated string - then you just have to do an implode (no loop) to $attribute:

$att_ref = implode(",", $attribute);

But id don't understand why you don't just assign the whole $attribute array to the $_SESSION ?!!

johny_d 23 Junior Poster in Training

Use array_slice function
Read here how: http://php.net/manual/en/function.array-slice.php

You should read the php manual first and learn th basic stuff from there, and then go and start programming!

johny_d 23 Junior Poster in Training

mysql_query("DELETE p.*, t1.*, t2.*, t3.*, t4.*, t5.*, t6.*
FROM product AS p, table_1 AS t1, table_2 AS t2, table_3 AS t3, table_4 AS t4, table_5 AS t5, table_6 AS t6
WHERE p.id = $product_id
AND t1.product_id = $product_id
AND t2.product_id = $product_id
AND t3.product_id = $product_id
AND t4.product_id = $product_id
AND t5.product_id = $product_id
AND t6.product_id = $product_id")
or die(mysql_error());

This includes in the same query the delete from product table as well, so you don't have to put it in a different query

johny_d 23 Junior Poster in Training

I've just gave you the full query with the solution in the post above!
Did you even run that query?

johny_d 23 Junior Poster in Training

You would probably have to loop through the resultset and assign each row to an array; you can't just split the resultset;
it might be easier/faster to just have to queries with their own resultset

johny_d 23 Junior Poster in Training

Counting for locations:

SELECT COUNT(*), fieldID, fieldValue 
FROM itemfield 
WHERE fieldID = 8
GROUP BY fieldValue

just change the fieldID with the ID of other counting criteria (dwelling type, make, etc)

johny_d 23 Junior Poster in Training

Are you sure you have records that match all the joins at the same time? Cause there is nothing wrong with the query.
Try using LEFT JOIN instead of JOIN and see what it returns.
This will return all the rows in your clients table and either fields with data (for matching rows) or empty fields for non matching rows, for the other tables.

johny_d 23 Junior Poster in Training

Hi,
Have you found a solution for this yet?
If not, then... 1. can you put the three tables in a zip and attach them here so I can replicate them locally and try some changes?
and 2. 'gold' in this query is just an example for any dynamic input keyowrd, like a search string, right?

johny_d 23 Junior Poster in Training

tnx.it works! (ms mult:P)

Cu placere ;)

johny_d 23 Junior Poster in Training

Why do you have to use replace?
Cant you just append the random password to the and of the string without XXXXX ?
Like this

<?php
$password = rand(12345,98765);
$stringtoparse = 'Your new password is ' . $password;
echo $stringtoparse;
?>
Carrots commented: Thanks for the help :) +2
johny_d 23 Junior Poster in Training

Actually, what colweb said will not end up with what you want, since your implode will put a comma between elements from each row, but will results from different rows wil not have a comma between them.

The double values you get is from the fact that you use mysql_fetch_array - which returns in fact 2 sets of data, one with numeric keys for fields and one with associative keys;
your $info variable will be an array like this:
$info[0] = 'value of umiditate';
$info = 'value of umiditate';
When you implode $info (which you shouldn't), you actually join the 2 values from $info, which are in fact the value of the same field - hence, the double value separated by comma.
I recomend you use mysql_fetch_assoc in your scripts since it is faster than mysql_fetch_array and doesn't bring back two sets of data.

So, you can do this two ways:
like colweb said, but with a small adjustment.

$comma_separated = '';
while($info=mysql_fetch_assoc($x))
{
$comma_separated .= $info['umiditate'] . ','; // 
}
$comma_separated = substr($comma_separated, -1, 1); // remove the comma at the end
print "$comma_separated";

or

while($info=mysql_fetch_assoc($x))
{
$comma_separated[] = $info['umiditate']; // 
}
$comma_separated = implode(",", $comma_separated);
print "$comma_separated";
johny_d 23 Junior Poster in Training

You're welcome!

johny_d 23 Junior Poster in Training

UPDATE:

The query returns "0 row(s) affected". I'm still looking at the code, but if you find something, do let me know.

The code is fine, but it's probably something that don't match the real structure of your tables. Or maybe you don't have users/dealers in the db that match those conditions in the query.
Do a mysql export for the dealers and users tables structure and data, put it in a zip and post it here as an attachment, so I can test with the same structure and data you have.

johny_d 23 Junior Poster in Training

You're welcome; do a search for "php variables scope" so you learn where and how variables are available.

Cheers

johny_d 23 Junior Poster in Training
UPDATE user AS u, thread AS t, threadoffering AS to
SET u.points = u.points * 1.05
WHERE t.threadid = to.threadid 
AND to.year = 2010
AND to.season = 'spring' 
AND t.threadLocation = CS
AND to.user = u.userid
AND u.userid > 1

You have to join somehow user table to threadoffering table (I supposed you have a userid field in user table that corresponds to user (or a userid) field in threadoffering table. If it's not, you should have it!
The rest of the query is pretty clear I think.
And the points field should be of type float or similar, so you can get decimals there (5% added to 3 point results in 3.15 points, which cannot be storred in an integer field)

johny_d 23 Junior Poster in Training

That's because the graph class you use to output the image is trying to set some image headers, but you already outputed some stuff (from your print commands) before it, which php don't allow.
So:
1. This should fix your error: remove all the prints before phpgraphlib.php; leave only the error dies (if the script dies, it won't get to the graph lib anyway)
2. Just an improvement: select both mysql values in a single select:

$result = mysql_query("SELECT umiditate, temperatura FROM parametrii");
$info = mysql_fetch_array($result);
$xi=array($info['umiditate']);
$yi=array($info['temperatura']);
johny_d 23 Junior Poster in Training

Here's a very simple mysql solution:

<?php
mysql_query('UPDATE dealers AS d, (SELECT agent, COUNT(*) AS agentcount, registration_timestamp FROM users GROUP BY agent) AS u
SET d.thisperiodusercount = u.agentcount + d.usercountbalance
WHERE d.username = u.agent AND u.registration_timestamp > d.registration_timestamp AND u.registration_timestamp < d.expiredtime') or die(mysql_error());

I'd suggest you don't use the dealer username as a key in users table; use dealer ID instead! It's basic mysql:
first of all, numeric keys have amuch smaller fingerprint in the db and work much faster than textual keys
second: if you used username as a key and a dealer should change his uername at some point, you would have to update all the rows in the users table that correspond to that dealer ;)

x86phre3x commented: The code provided by this user works exactly as what I intended and it's simpler than what I have imagine. +0
johny_d 23 Junior Poster in Training

This works, of course, but it's not a very elegant solution and if you have many checkboxes on the page than (say 50) you will have to write that code 50 times, which I don't think you'll like :)
So, another easier solution is to set the names of the checkboxes to that they are sent to the next page as an array, then, on the next page, you just have to loop through the array:

<input type='checkbox' name='boxex[1]' value='item1' /><br />
<input type='checkbox' name='boxes[2]' value='item2' /><br />
.....
<input type='checkbox' name='boxes[9]' value='item9' /><br />
<input type='checkbox' name='boxes[10]' value='item10' />
<?php
if(isset($_POST['boxes']) && !empty($_POST['boxes'])) {
foreach($_POST['boxes'] as $k => $v) {
print $v . '<br />';
}
}
else {
print "Nothing checked";
}
?>
johny_d 23 Junior Poster in Training

It's probably because you don't have the $dbc available inside that function; you have to either pass it as a parameter to the function
like: function($dbc) { ....
or set it as a global variable inside that function
like: function() {
global $dbc;
.....

johny_d 23 Junior Poster in Training

You can do it like that, but that's not the optimised way to do it.
You have what is called multiple-to-multiple relationship (many users with many hobbies).
So the principle to connect one to the other is to have a table that defines each one (one table for users and one table for hobbies) and a third table to tie one to the other.
This would be like this:

Users_table:
user_id | username |....
1 | John | ...
2 | Bill | ...
3 | Kate | ...
...

Hobbies_table:
hobby_id | hobby_name
1 | stampcollection
2 | fishing
3 | photography
...

Users_to_hobbies_table
id | user_id | hobby_id
1 | 1 | 1
2 | 1 | 3
3 | 2 | 1
4 | 2 | 2
5 | 3 | 2
6 | 3 | 3
...

We only store the usernames and hobbies names once and than we only work with their IDs, which are very fast and very lightweight for the database to manage.

The third table tells us that:
John like stampcollection and photography
Bill likes stampcollection and fishing
Kate likes fishing and photography

Let's say you want to find users who like phishing, you would do a query like this:

SELECT u.* FROM users_table AS u, hobbies_table AS h, users_to_hobbies_table AS …
almostbob commented: newly designed table is 400MB smaller, and noticebly faster +1
johny_d 23 Junior Poster in Training

Try this:

<a>a href="results.php?fl=A">A</a>
<a>a href="results.php?fl=B">B</a>
$fl =$_GET['fl']; // fl - First Letter
if (preg_match('#^[a-z]{1}$#i',$fl)) { // check if it is an allowed value - letters from a to z in lower/upper case

$result = mysql_query("SELECT id,high_school FROM high_schools WHERE high_school LIKE '$fl%'";
......
}

For that code to work faster, it's probably a good idea to have an index on the 'high_school' column in your mysql table

johny_d 23 Junior Poster in Training

You have a problem in the way your query string is written (because of the way you wrote it, you missed some spaces, between auth and where and between '$userid' and and:

$query="select * from auth" 
."where name='$userid'"
."and pass=password('$password')";

this query is, in fact, this:

$query="select * from authwhere name='$userid'and pass=password('$password')";

which, obviously, is wrong;
And the part with the password is probably wrong: it should probably be pass='$password'

So, try this query in your script:

$query="select * from auth where name='$userid' and pass='$password'";

Since you don't escape the userid and password variables, you are also in trouble if any of them contains a ' or " or # and maybe other special characters.

Also, from the way your script looks, it seems to me that you are using register_globals = on. This is very bad. Set it to off and get your post variables like this:

$userid = $_POST['userid'];
$password = $_POST['password'];
johny_d 23 Junior Poster in Training

$item = mysql_fetch_array($item_query);

means $item is an array an you cannot put an array in an echo statement; this is why you get nothing.
You need to use $item in your "echo...."
You also have a sintax error: in

$foo =& creature_stats( item, $id_creature );

since item is a variable, it needs a $ sign in front; this is a very good reason why you get a blank nothing :)

johny_d 23 Junior Poster in Training

First of all, why do you require the "Wordsarray.php" file in each cycle of the while loop?
You should include (require) that file only once, before the loop and than do the while loop.
Than, about your error, I can only guess here, since you didn't provide the $normal and $tidied arrays: my guess is the problem is from one of the values in the $normal array and the opening and closing slashes ("/" and "/i") of your matching strings.
Let me expalin: if one of the values (strings) from $normal array contains a slash (/), let's say the string is "abcde/gb--", than your matching string in your expression becomes "/abcde/gb--/i"; now, the problem is that, in this case" your script thinks the second slash (the one before gb--) is the closing one (instead of the third one, the one before i), so it takes every character after that slash (gb--/i) as a pattern modifier, which, of course, is an error: "g", "b", "-" are not valid modifiers.
So, check to see if you have any slash "/" in the values of the $normal array, and if you have, you must escape them (put a backslash before any slash) before inserting them in the regular expression.
You can also use some other delimiter ("#" for instance), if it doesn't appear in your pattern strings.
From PHP manual: If the delimiter character has to be used in the expression itself, it needs to be escaped …

johny_d 23 Junior Poster in Training

You're welcome ;)

johny_d 23 Junior Poster in Training

Well I think it kind of make no sense of using both methods in the same url:
if you like query strings, stick to them - index.php?act=games&task=play&game=534

otherwise, if you like or want to use mod_rewrite, than stick to mod_rewrite - mysite.com/games/play/534.html

Do it the way you want or like, but don't mix them ;)

johny_d 23 Junior Poster in Training

You should use:
for ($i = 0; $i <= 28; $i++) ......
since the keys of your $random_array are from 0 to 28

johny_d 23 Junior Poster in Training

I guess so

johny_d 23 Junior Poster in Training

$random_array = array_rand($sAdText, 3);

johny_d 23 Junior Poster in Training

<title><?php echo $title; ?></title>
where $title has a value returned by your php script; for instance: the title of an article from the database, the name of the current category, the name of the site if you are in the homepage etc.; look at this forum for example.

johny_d 23 Junior Poster in Training

Here's a statistic from one of my sites, but I can tell you that is about the same from all my other sites:
1024x768 (45.9%)
1280x800 (12.3%)
800x600 (10.4%)
1280x1024 (9.7%)
1152x864 (3.2%)
1280x768 (2.2%)
1680x1050 (1.9%)
1400x1050 (0.5%)
1280x960 (0.7%)
Others (13.2%)

As you can see, most of the users are on 1024x768 px; there is still some important percent of people using 800x600; as for the lower or higher resolutions, you can see they are very few.
I think fixed width sites or fluid inside some limits are the best options.
If you use CSS for the layout (the reccomended way to do it), fixed width site layouts are easyer to control and make compatible with more browsers than fluid designs.

Fluid design with a minimum and a maximum width (for instance min. 760px width - for 800x600 - and max. 960px width - for 1024x768) are also a good alternative, although it is more difficult to make compatible with different browsers (IE for instance).

The fluid layout is good as it adjusts to many different resolutions, but I think it has two very big drawbacks:
- is hard to keep the layout tha way you want on different screen resolutions (this may not be a problem if you have a simple, Google like layout)
- on big resolutions, your content spreads too much, being very hard to read

johny_d 23 Junior Poster in Training

If you use mod_rewrite, why don't you use it all the way???

RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([0-9]+)/$ index.php?act=$1&task=$2&game=$3

or

RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([0-9]+).html$ index.php?act=$1&task=$2&game=$3

That would be:
mysite.com/games/play/534/
or
mysite.com/games/play/534.html

or whatever other variation of that you want ;)

johny_d 23 Junior Poster in Training

I'm glad to be of help!

johny_d 23 Junior Poster in Training

Here's your code:

This is 'show.php'

<p>header</p>
<hr />
<?php
if (isset($_GET['show']) && $_GET['show'] == 'warning') {
 echo '<p><a href="show.php">Close warning</a></p>';
 include ('warning.html');
 echo '<p><a href="show.php?show=disclaimer">view disclaimer</a></p>';
 }
elseif (isset($_GET['show']) && $_GET['show'] == 'disclaimer') {
 echo '<p><a href="show.php?show=warning">view warning</a></p>';
 echo '<p><a href="show.php">Close disclaimer</a></p>';
 include ('disclaimer.html');
 }
else {
 echo '<p><a href="show.php?show=warning">view warning</a></p>';
 echo '<p><a href="show.php?show=disclaimer">view disclaimer</a></p>';
 }
?>
<hr />
<p>footer</p>

This is 'warning.html'

<h1>WARNING TEXT</h1>
<p>askdh fasf asdkfhas djfhakdhf ashfkjash fdhf kajsdhfkashf asjdfhds</p>

and this is 'disclaimer.html'

<h1>DISCLAIMER TEXT</h1>
<p>jdshf gdhsfg dsfhg dsfgasdowe[ wfnsdfg lsdjfgjdslfjgdsjf gljdslfjgldskfjg sjfklsjdfklgj skldjsdjfg dsjfklgjdsklfgj dskljfgklsdgfkl dsjlfgkjdsf</p>

And to kkeith29, thanks for the reply; we all have our bad days; we're cool now ;)

johny_d 23 Junior Poster in Training

to the header file;
if you don't know exactly what the path is, wright here the path to both your 'header.php' file and the main file (the one that tries to include the header), starting from the root of your server; for instance, if your header.php is in 'www.yourdomain.com/php/header.php' the absolute path (starting from the root of your server) is '/php/header.php'

johny_d 23 Junior Poster in Training

Hey, kkeith29, don't take it so personally; I didn't meant you were stupid; I wasn't even replying to you, but to Syakoban; your solution is very good if you want to reload the page; I just understood something else from Syakoban post (to be more clear, I understood he wanted to load some content in the page without reloading the page) and I pointed out to him the differences so he can learn an choose what best suits him (or her :) ).
I am sorry if my post offended you. I asure you that wasn't my intention. Ok?

johny_d 23 Junior Poster in Training

That's exactly what I said: the path to the file is wrong.
Try to use a relative path, instead of an absolute path and make sure it is correct.

johny_d 23 Junior Poster in Training

Actually, kkeith29 example doesn't load new content in the original page; it just reloads the page with a parameter passed through the $_GET variable, and shows some text as a response of that parameter.
Since php is a server side script, which means it is processed on the server and only the result of the process is sent to the client (browser), in order to process any piece of php code (like an 'include' request), that piece of code must be passed through the server; you cannot execute php code inside the user browser; for that, you need to use a client side script (like javascript).
A simple approach to what you want is to insert in your page, from the beginning, in a hiddend block (div, p etc.), the piece of text that you want to show on click, and make a javascript that simply shows that block of text when you click the link.

If the block of text (or whatever it is) must be the result of a php script, than the only way you can insert that on the page on client side (without reloading the page) is through AJAX, which is, simply put, javascript communicating with the server (the php page in your case) without the page reload.

Eko commented: excelent +1
johny_d 23 Junior Poster in Training

You pobably have a sintax (writing) error in your 'header.php' file; check that you have closed all the brackets and parenthesis and also that you have sthe ';" at the end of every line of code etc.
Yu also might have a wrong path to the file: '/php/header.php' means the php folder under your root directory; my guess is that you have an error in your header.php file, but on your local system the path to your file is wrong and php passes over the file (try to use require instead of include and see if you get an error) while on your server, the path is ok, causing the main script to really load the header.php (with the error in it) which gives you tha blank page... or the vice-versa: the local path is ok but the remote path is wrong; check that everything is right both local and remote.
Than, of course, I may be wrong :)

johny_d 23 Junior Poster in Training

Whatever you say :)

johny_d 23 Junior Poster in Training

Search engines don't see code as duplicate content. They see content as duplicate content. Newbies don't understand that search engines don't rank code. It's the content that matters. Also, every site has a ton of duplicate content on it. It's called the site layout.

stymiee, if you weren't so full of what you know and so convinced that everybody else is a newbie, you would understand that I wasn't talking about the code of page as the "html tags" but rather about the full text version of the page (tags stripped), which is what search engines see, as opposed to the visual version of the page.
Anyway, we can argue for days, pros and cons of one version against another. I made my point, you made yours... and anybody trusts whoever they want, and learn whatever they want.

johny_d 23 Junior Poster in Training

Of course the links are inportant for ones site, but more important than them is the UNIQUE content of your pages; if you know the basics about SEO, you must know that; also, it's a well known thing that search engines give more importance to the information at the beginning of the code and less importance as the code goes to bottom;
so, in your oppinion: if you have 10.000 pages of articles on your site and all off your pages have the first 500 rows of code almost identical and only the rest different is better than having all those pages different and filled with interesting content close to the first lines of code and than the repeating links?
It is true that search engines will only parse a limitted amount of links on each page (arround 100), but who says that those links have to be on top of page to be paresd???

devesh9392 - a good way to see how search engines "see" you page is to remove the CSS formating and see how your pages look without it. The search engines don't mind the visual layout of your page but they really mind the "layout" of the content behind your page.
Also, remember that search engines try to bring in front those pages that are more likely to be liked buy your potential site visitors. What this means? this means that, after removing the CSS formating of your pages, look …

johny_d 23 Junior Poster in Training

MitkOK is right with his code; but you have bigger problems before that:
- first of all, don't mix javascript function calls with php defined functions; get rid of those onClick="<? ....; those are javascript functions calls, but the functions you defined are php
- second: avoid using short open php tags (<?); use instead the long ones (<?php) that work on every server configuration;
Your code might work just fine without any correction (just with MitkOK addon code), but if you try to learn something here, than you should take the above into account.

johny_d 23 Junior Poster in Training

Can't you see this is spam???
This guy has two posts that advertise his template directory; hey, admin, you should do something about it, before he starts 100 posts advertising his site.

johny_d 23 Junior Poster in Training

You're welcome ;)