minitauros 151 Junior Poster Featured Poster

Just check whether your checkboxes are checked or not, and if yes, what their value is? All checkboxes and their values can be found in the $_POST data. :)

minitauros 151 Junior Poster Featured Poster

Hehe you're welcome :).

minitauros 151 Junior Poster Featured Poster

$string_exp = "/^[A-Za-zé\.¸UûÙùàÀèÈéÉïÏîÎôÔêÊçÇ \,\\\'\-]+$/";

Although I'm not sure if all those special characters will work. Never tried it, so I'm not certain.

minitauros 151 Junior Poster Featured Poster

You could try: preg_match('/^\+?55[0-9]+$/', $string);

\+? means: a + 0 or 1 times,

55: both need to be present

[0-9]+, any number, 1 or more times.

minitauros 151 Junior Poster Featured Poster

Just a wild guess, but maybe you could explode on a special character (the enter character, \n)?

That would return an array of which each key would contain a line of text.

minitauros 151 Junior Poster Featured Poster

I don't know everything about regexps, but a dot should be escaped, or it will be treated as "any character". A dot matches any charachter if it is not escaped properly.

Same goes for the comma and dash, backslash and ', in other words, all characters that have a function within a regexp. They should all be escaped properly. [A-Z] means A to Z, while [A\-Z] means A, - and Z.

minitauros 151 Junior Poster Featured Poster

To start at a value other than 1, add

AUTO_INCREMENT xxxxx

to a create query, like CREATE TABLE bla (this and that) AUTO_INCREMENT 1000

minitauros 151 Junior Poster Featured Poster

It means that PHP can't find the file specified. Are you pointing to the right file?

minitauros 151 Junior Poster Featured Poster

Change [L] to [L,R] might work. I'm not a .htaccess pro but I know that the R stands for "Redirect", so that's the first thing that comes into my mind when I read your issue.

minitauros 151 Junior Poster Featured Poster

It's for example to show other coders that are working on the same project as you how they should use your class.

minitauros 151 Junior Poster Featured Poster

What cereal says. You need to add an underscore between the $ and SERVER, which makes it $_SERVER instead of $SERVER.

minitauros 151 Junior Poster Featured Poster

Yes, you can create a graph using commands like imageline etc. (http://php.net/manual/en/function.imageline.php)

You should search for a PHP Graph tutorial! :)

minitauros 151 Junior Poster Featured Poster

I'm sorry, I'm not very well acquainted with the submodal feature. The only thing I can tell you, is that I do not see an input field with the name "Notes" - which is required in your insert query.

minitauros 151 Junior Poster Featured Poster

Your form appears not to have an input named "Notes" - that's the index PHP says you're missing, and that might be the problem.

minitauros 151 Junior Poster Featured Poster

May I ask why you're using two tables to display only one banner?

minitauros 151 Junior Poster Featured Poster

You mean uploading all files in a folder and attatching it to an email?

minitauros 151 Junior Poster Featured Poster

I now have:

RewriteCond %{REQUEST_URI} forum
RewriteRule .* /forum [NC,R,L]

This works for the url http://mywebsite.com/forum, but when I try to load an image named "forum", it won't load. It does load, however, when I rename it to "forun", so it's definately a problem in my .htaccess. How can I fix this?

minitauros 151 Junior Poster Featured Poster

Hello there,

I'm trying to create a rewrite condition for a set of rewrite rules. Currently this is what I have:

HTML and CSS Syntax (Toggle Plain Text)

RewriteCond %{HTTP_HOST} ^/?forum [NC]
RewriteRule ^([\w]+)/([\w]+)/?$ index.php?p=$1&s=$2 [NC,L,C]
RewriteRule ^([\w]+)/?$         index.php?p=$1 [NC,L]

What I want is to have the following uri, http://www.mywebsite.com/page1/page2, load a different page, http://www.mywebsite.com/index.php?p=page1&s=page2, by using mod rewrite.

Except when the query part starts with "forum" (for example: http://www.mywebsite.com/forum). When it does start with forum, I would like to really load the "forum" folder, instead of loading index.php?p=forum. However, my rewrite condition is not working right now. Can anyone please help me?

minitauros 151 Junior Poster Featured Poster

You could try finding a tutorial somewhere? :) I'd suggest www.good-tutorials.com

minitauros 151 Junior Poster Featured Poster

Hello there,

I'm trying to create a rewrite condition for a set of rewrite rules. Currently this is what I have:

RewriteCond %{HTTP_HOST} ^/?forum			[NC]
RewriteRule ^([\w]+)/([\w]+)/?$				index.php?p=$1&s=$2 [NC,L,C]
RewriteRule ^([\w]+)/?$					index.php?p=$1 [NC,L]

What I want is to redirect http://www.mywebsite.com/PAGE1/PAGE2 to http://www.mywebsite.com/index.php?p=PAGE1&s=PAGE2, except when the URI starts with "forum" (for example http://www.mywebsite.com/forum). However, my rewrite condition is not working right now. Can anyone please help me?

minitauros 151 Junior Poster Featured Poster

Exactly what are you trying to achieve? :p

minitauros 151 Junior Poster Featured Poster

You also have an error on line 79: mysql_quert($SQL) should be mysql_query($SQL)

minitauros 151 Junior Poster Featured Poster

The error must almost certainly be in the data you specified to connect to your MySQL database. For example you could have set a wrong username, password, host, etc. to connect to your database. Make sure you double check it, and then try again :).

minitauros 151 Junior Poster Featured Poster

You could make a full horizontally oriented image, maybe. What I mean is for example when you retrieve data from your database, you coun't how many boxes you're gonna have to make for each column, then you place those boxes underneath eachother (you will need to calculate where you're gonna place them, so you will be able to calculate where you should draw your lines from and to, as well) and connect them with lines.

Something like:

A -- G
|-- D
B -- A
|-- C
|-- D -- X
|-- Y
C -- W

minitauros 151 Junior Poster Featured Poster

Can't you just select the amount of votes that an option has received from the pollvotes column, and then display the result behind the poll option?

minitauros 151 Junior Poster Featured Poster

The "var" prefix was used in PHP 4. In PHP 5, you don't need to use the word "var" to declare a variable. In PHP 5, however, a warning will be generated if error handling is set to E_STRICT.

minitauros 151 Junior Poster Featured Poster

Bump

minitauros 151 Junior Poster Featured Poster

Because using the <base> tag is giving me some problems lately, I'm curious about what the best solution is to use together with mod rewrite.

I use mod rewrite a lot, and the <base> tag helps me to keep the links to my css files, for example, working. I link to those css files in a way of ../, and if I rewrite my url using mod_rewrite, ../ would point to the wrong directory.

So my question would be: How can I point to my css files correctly when using mod_rewrite, without using the <base> tag (in PHP)?

minitauros 151 Junior Poster Featured Poster

Because using the <base> tag is giving me some problems lately, I'm curious about what the best solution is to use together with mod rewrite.

I use mod rewrite a lot, and the <base> tag helps me to keep the links to my css files, for example, working. I link to those css files in a way of ../, and if I rewrite my url using mod_rewrite, ../ would point to the wrong directory.

So my question would be: How can I point to my css files correctly when using mod_rewrite, without using the <base> tag (in PHP)?

minitauros 151 Junior Poster Featured Poster

It's not completely clear to me what your question is. Are you asking what SQL command you should use, are you asking what Javascript code you should use, or are you asking something else?

minitauros 151 Junior Poster Featured Poster

I already did, and I found some tutorials on the timer functions, but none of them explains how to execute such an action only once: I don't know how to reset the timer. They do explain it, but only for JQuery, and I'm not using JQuery at the moment. Is there any way to do it without JQuery? Cause I don't know where to place the clearTimeout() function, and it also does not seem to reset the timer, only to pause it.

minitauros 151 Junior Poster Featured Poster

Hello there,

I'm running into a minor problem. I want to execute an onKeyUp action after a short delay when a key is released. So for example when the user gets his finger off the "y" button, I want to execute an action related to that "Y" after 1 second.

BUT: I want to execute it only once. With the script I now have, 10 timers start running when the user types in 10 letters, which means 10 actions are executed, each after 1 second after releasing a key, while I only want to execute 1 action.

So when the user types in "hello", an action is executed for each letter he typed in. What I want is the timer to reset after he types a new letter within a second after he types a letter. So when he types "hello" within like a second, only one action is executed. This script:

setTimeout(function(){

actions..

}, 1000);

Keeps resetting the timer over and over. Any suggestions?

minitauros 151 Junior Poster Featured Poster

Almost every time such an odd problem occured in one of my projects, it was like only one letter or one line that was written wrong or contained a spelling mistake that was causing the problem. You really need to check EVERYTHING very closely.

session_start(); should be the first line on every page, and when you log out you should use session_destroy();, at least to try if it works.

minitauros 151 Junior Poster Featured Poster

I think you can achieve what I think you want to achieve by creating a .htaccess file. Try seaching Google for htaccess tutorials or something like that :).

With a .htaccess file you can rewrite your URI's. For example http://www.example.com/index.php?query=hello could be displayed as http://www.example.com/index/hello.

minitauros 151 Junior Poster Featured Poster

For security you should at least do both: create a .htacces file AND check if the user visiting the page is allowed to perform the actions he is about to perform (by, for example, matching his user rank - which was set when he logged in - against the user rank that is required to perform the action).

minitauros 151 Junior Poster Featured Poster

Sha1 is safer than md5, and it's also built in in PHP, so why not use sha1? :) Where md5 returns a 32 character long encrypted hash, sha1 returns a 40 character long encrypted hash. It may not seem like that's a lot of difference, but it is!

minitauros 151 Junior Poster Featured Poster

It should be:

if (!preg_match("/^[A-Za-z0-9]{3, 20}$/i", $_POST['brugernavn']))

The {3, 20} part checks if the length is between 3 and 20 characters.

pritaeas commented: Well spotted, missed the comma. +13
minitauros 151 Junior Poster Featured Poster

I'm using Google Webfonts myself, but it's too bad that not all browsers know how to work with custom fonts :(.

diafol commented: thanks for the tip - I've been messing with a DIY solution +13
minitauros 151 Junior Poster Featured Poster

If you put a "From:...." in your $headers, there's no need to add it again in your additional parameters :).

minitauros 151 Junior Poster Featured Poster

Thank you for your reply, I'll seriously consider to start using JQuery. I solved my problem by using a completely different script:

function doAjaxForm(url, target_element_id, img_url, form_id, form_field_names)
{
    var form_elements = document.getElementById(form_id).elements;
    var query_string = '';

    for(i=0; i<form_elements.length; i++)
    {
        if(i==0)
        {
            if(form_elements[i].name && form_elements[i].value)
                query_string = '?' + form_elements[i].name + '=' + form_elements[i].value;
        }
        else
        {
            if(form_elements[i].name && form_elements[i].value)
                query_string += '&' + form_elements[i].name + '=' + form_elements[i].value;
        }
    }
minitauros 151 Junior Poster Featured Poster

I kept trying but replacing

query_string = form_field_names_array[i] + '=' + document.form_name.form_field_names_array[i].value;

by

query_string = form_field_names_array[i] + '=' + document.forms[form_name].elements[form_field_names_array[i]].value;

also returns an error, while the same line

document.forms[form_name].elements[element_name].value

BEFORE the start of the for loop, does not return an error.

minitauros 151 Junior Poster Featured Poster

Hello. I'm not so good at Javascript, but I tried to write some code to obtain some form values and write those to a query string to use in AJAX.

It seems to be working partially, but I don't understand what is going wrong. What happens is that in the for loop the 'document.form_name.form_field_names_array.value' part doesn't seem to return a value. It is worse even: the script completely stops executing at that part. When I remove that part from the line in the for loop, it doesn't stop executing, so I guess that's where the problem is?


function doAjaxForm(url, target_element_id, img_url, form_name, form_field_names)
{
    // Create the GET query string from the form_fields
    form_field_names_array = form_field_names.split(',');

    for(i=0; i<form_field_names_array.length; i++)
    {
        if(i==0)
        {
            query_string = form_field_names_array[i] + '=' + document.form_name.form_field_names_array[i].value;
        }
        else
        {
            query_string += form_field_names_array[i] + '=' + document.form_name.form_field_names_array[i].value;
        }
    }
    
    // Result: something like query_string = field1=value1&field2=value2&etc...

// Rest of the code (the AJAX) is working.
minitauros 151 Junior Poster Featured Poster

It's indeed what Zero13 says. Your function needs an id to make use of the getElementById function. However, you're not sending the id to the function when you call it in your HTML. You could try replacing onClick="getId(id);" by onClick="getId(this.id);" if you want to send the id from the element that has the onClick action attached to it.

minitauros 151 Junior Poster Featured Poster

Lines 28 - 30:

if($err!=""){
echo "Error in $sql: $err\n";
echo "Invoice Prep completed";

You place an opening bracket there, but you never close it.

minitauros 151 Junior Poster Featured Poster

Well, I don't think there's much difference between executing 4 different queries in one query and executing 4 different queries apart from eachother.

I've never tried it, but I don't think executing 4 counts in one query will work. Besides that, COUNT just counts the rows that are selected, so if your first query counts 3 rows, and the second one counts 6 rows, the result will be 6, not both 3 and 6 (for as far as I know).

So I'd say: just execute the 4 queries apart from eachother. That'll work for sure.

minitauros 151 Junior Poster Featured Poster
minitauros 151 Junior Poster Featured Poster

So you already both have them as child classes of a class? Then it would be impossible to derive methods from the one child class into the other, because in PHP each class can only have one parent class. For as far as I can see, you'll have to type all code twice, OR add it to their common parent class.

I hope I'm not completely missing the purpose of your question :p.

minitauros 151 Junior Poster Featured Poster

Perhaps you should read about extending classes :). Child classes implement all functions of their parent. So if you have for example child class getUserByRid, which is the child of getUserByUid, it would look like:

class getUserByUid
{
// code..
}
class getUserByRid extends getUserByUid
{
// this one contains all methods from getUserByUid. You can write new methods for this class as well, but getUserByUid won't be able to use them.
}

Is that what you mean?

minitauros 151 Junior Poster Featured Poster

Usually, as Ardav says, visitors cannot even see your PHP code. Have you ever tried right clicking a website -> view source? Do you see PHP code there? :) (If that's what you mean).

minitauros 151 Junior Poster Featured Poster

For as far as I know, executing a COUNT instead of count_num_rows is faster, performance wise.

Your new query would look like

SELECT COUNT(a_unique_field_occuring_in_every_record_that_is_selected) AS num_rows, * FROM products ORDER BY dateadded DESC

I'm not 100% sure if it is faster though, but with this query, you could use mysql_fetch_assoc to fetch your results. $fetch will then be the number of rows.