minitauros 151 Junior Poster Featured Poster

Yes that's probably, as I just mentioned, because you don't close your line 9 with a semicolon (";"). Try removing the semicolon from inside your quotes in the following line:
$sql="select image from images where id='$_GET[id]';";

Which would make it become:
$sql="select image from images where id='$_GET[id]'";

Then add the mysql_real_escape_string() functionality, like this:
$sql="select image from images where id='" . mysql_real_escape_string($_GET[id]) . "'";

And then place a semicolon at the end of the following line:
$row = mysql_fetch_array($result)

Which would make it become:
$row = mysql_fetch_array($result);

minitauros 151 Junior Poster Featured Poster

$sql="select image from images where id='$_GET[id]';";

I think you should remove the first semicolon in that line and place it after the following line:

$row = mysql_fetch_array($result)

Next question: What is the error you are getting? :)

Also, if you are using PHP's mysql functions to connect to your database, you might want to consider properly escaping external input to your database, like $_GET['id']. I would replace that by mysql_real_escape_string($_GET['id']) for starters. You can read more about the function here.

minitauros 151 Junior Poster Featured Poster

Types of errors in php:
1.) Parse Error or Syntax Error,
2.) Fatal Error,
3.) Warning Error,
4.) Notice Error

And of those number 1 and 2 will stop executing your script, while 3 and 4 will not. In other words: in case 1 and 2 your script will not run at all, and in case 3 and 4 you will see an error in your output (depending on how you set your error_reporting()), but you do get output.

minitauros 151 Junior Poster Featured Poster

Glad to hear a miracle has happened :p

minitauros 151 Junior Poster Featured Poster

So when you inspect your URL on page, what does it look like? I mean this url:

"manage-products-2.php?prod_id='.$row[0].'"

Does it look like, for example, manage-products-2.php?prod_id=5 ? In other words: is the prod_id really given?

What is strange though is that your whole $_GET is empty, because even if your prod_id would be empty, you should still get "prod_id = null" when you var_dump() your $_GET. Does the URL on your manage-products-2.php page look as it should? I mean, when you load the page in your browser, does the link include the "prod_id=x" part?

minitauros 151 Junior Poster Featured Poster

I'm not targeting a specific country, it is to be read in multiple countries in the EU, so this information is of a lot of help :). My basic English is fine (at least I hope so), it's just the stuff I don't read or speak everyday that I get unsure about. Thanks for your help everyone!

almostbob commented: kudos, english is about the weiredest language +0
minitauros 151 Junior Poster Featured Poster

That error means that you do not have your CURL extension enabled. Are you running a local server or a hosted server? If you are using a local server, you can navigate to the folder in which your php.ini file resides (for me that's "\xampp\php"), open up that php.ini file, ctrl+f to find "curl" and remove the semicolon (";") in front of that line (if a semicolon is there) to enable the CURL extension. You will have to restart your server for changes to take effect.

minitauros 151 Junior Poster Featured Poster

Well if your $_GET is empty, it is usually because there is something wrong with the URL that was used to load your page. Does your URL contain all the key=value pairs you need? (E.g. prod_id=1&name=dhani etc.)

minitauros 151 Junior Poster Featured Poster

Did you:

  1. Check if you started a session in both files, using session_start()?
  2. Validate that each $row actually contains the values you expect it to contain? You can use var_dump($row), for example, to output a row (or print_r($row)).
  3. On your second page - manage-products2.php - you could check if $_SESSION and $_GET contain any values, by using those same var_dump() and/or print_r() functions.

Could you tell us the results of these tests? :)

minitauros 151 Junior Poster Featured Poster

You want to give the user an alert and then redirect him? Why not redirect him and then give him the alert? :)

minitauros 151 Junior Poster Featured Poster

Ah so I can use either? Thanks for your advice =).

minitauros 151 Junior Poster Featured Poster

I'm writing a report about public transport, and I'm not English, so I was wondering if anyone could help me with this: what is the correct way to use "public transport" in English?

For example:

Group x uses public transport to get from A to B
Using public transport comes with certain difficulties for group x
Group x finds the price of using public transport too high

Should I say "public transport" or "public transportation"?

minitauros 151 Junior Poster Featured Poster

There is a way to add a password to it but I've never done it with PHP. A short Google search resulted in this command to be used:

exec('zip -P pass file.zip file.txt');

pass = password
file.zip = target zip
file.txt = file to zip (maybe you can specify a folder if you want to zip multiple files? I have no idea, you'd have to try :))

Unzipping would go as follows:

exec('unzip -P password file.zip');

(From: http://stackoverflow.com/questions/7712960/opening-and-creating-password-protected-zip-files-with-php and http://www.talkphp.com/general/3380-exec-zip-php-not-working-expected.html)

minitauros 151 Junior Poster Featured Poster

Plus there are huge communities for PHP, so if you get stuck you'll probably be able to get help fast. There are a lot of popular CMS'es being written in PHP, so if you want to use those, having some PHP knowledge can be useful.

minitauros 151 Junior Poster Featured Poster

Change this:

function browse($dir) {
    global $filenames;
    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != ".." && is_file($dir.'/'.$file)) {
                $filenames[] = $dir.'/'.$file;
            }
            else if ($file != "." && $file != ".." && is_dir($dir.'/'.$file)) {
                browse($dir.'/'.$file);
            }
        }
        closedir($handle);
    }
    return $filenames;
}

to this:

function browse($dir) 
{
    global $filenames;

    // Fill with names of files to exclude from your return array.
    $files_to_exclude = array(
        'file1.php'
    );

    if($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if($file == '.' || $file == '..') {
                //* Skip currentt and previous directory.
                continue;
            }
            elseif(in_array($file, $files_to_exclude)) {
                //* The current file is to be excluded.
                continue;
            }

            if(is_file($dir . '/' . $file)) {
                $filenames[] = $dir . '/' . $file;
            }
            elseif(is_dir($dir . '/' . $file)) {
                browse($dir . '/' . $file);
            }
        }

        closedir($handle);
    }

    return $filenames;
}

And see if it works :).

minitauros 151 Junior Poster Featured Poster

That is indeed a good one and you are right. However, I might have misformulated my question. What I need is for the regex to match only last name and first name, but to exclude "last" and "first" from the capture. All this must be done in one regex (at least that would be my ideal situation). So, for example:

([a-z]{8}|(?:last[ ])[a-z]{4}|(?:first[ ])[a-z]{4})

I want to find an unknown word consisting of 4 letters, and it MUST be proceeded by either "last" or "first", and I want to exclude that "last" or "first" from the capture, as I want to use $1 to capture the [a-z] part, because a word of exactly 8 chars may also match. Sorry I find it hard to explain the exact need :p. Thanks a lot for your input though!

minitauros 151 Junior Poster Featured Poster

Thanks priteas! I know how that works, I'm just wondering how I can exclude a regex group within a regex group :). So if the container group matches, I want to fetch only part of that match (by using ?: to exclude it, because I need to know the order of the matches).

minitauros 151 Junior Poster Featured Poster

Hm which error is being displayed right now, then? Not the same as before right? Sounded like you fixed that :). Is there a new one?

minitauros 151 Junior Poster Featured Poster

Anyone? :o

minitauros 151 Junior Poster Featured Poster

Maybe you could try and see what happens if you remove this check

mysql_num_rows($execute_get_record) == 0

from your file. So just fetch the results without checking if there are any. I don't usually use mysql_num_row, but maybe there's a problem with a comparison to 0 (I wouldn't know why but that's what I would try if I were you :))

minitauros 151 Junior Poster Featured Poster

Hmm well what do you get if you open your PHPMyAdmin and execute the following query?

SELECT * FROM Ordered_Cart_Items

If you do not get results, either your table may be empty or you might have miswritten your query.

minitauros 151 Junior Poster Featured Poster

If your server says

Warning: mysql_query() expects parameter 2 to be resource, string given in /nfs/c01/h12/mnt/3250/domains/zeta-clovis.sendairtime.com/html/support_mail/includes/find_order_records_function.php on line 37

about this line:

mysql_query($get_record_query,$connection)

then it means that $connection contains a string, while it should contain a resource, which means that your connect2DB2() function should be returning a resource (it should return the value of your mysql_connect() function). Did you check if it does? :) For there seems to be nothing wrong with your query.

And this is indeed what dorco and evolutionfallen already mentioned, sorry guys! Wasn't paying enough attention.

minitauros 151 Junior Poster Featured Poster

@minitauros, when I tried to echo the query, I got this message;
Resource id #14
Warning: mysql_query() expects parameter 2 to be resource, string given in /nfs/c01/h12/mnt/3250/domains/zeta-clovis.sendairtime.com/html/support_mail/includes/find_order_records_function.php on line 37

I meant echoing your query statement ^^. The command that you're giving to your MySQL. The query, like "SELECT FROM...". If you have that we can take a look and see if there's something wrong with it.

Also, what exactly is on line 37? Because in your starting post, on line 37 is:

$date_added = $returned_records['date_added'];

Which does not even look like a mysql_query() command :).

minitauros 151 Junior Poster Featured Poster

True that, hadn't even seen that the ^ was being used as delimiter ^^. Pritaeas, do you know which character you should use to match the start of a string if you use ^ as delimiter?

minitauros 151 Junior Poster Featured Poster

Hmmm if you want both to be valid, try:

'/^(\d{5})?([a-z.\-&\'",\/\\ ]+)(\d+)$/i'

This checks for:
Must start with a digit of length 5 (because of the {5} part) or no digits (because of the questionmark after the ")")
Must then be followed by one or more words
Must end in a number of any length, but with a minimum of one

The i after the last / sets the regex to be checked case-insensitive.
If you would like to change something in the first number, you could for example change {5} by {1,5} to define: a number with a length of 1 to 5.

minitauros 151 Junior Poster Featured Poster

Well there certainly seems to be no error on line 37 of the script you presented to us. Could you echo your query and post it here? (E.g. $query = [your query goes here]; echo $query; )

minitauros 151 Junior Poster Featured Poster

"x equals x" is written with 2 times an "=", not one time ;). You are now setting a new value for $n in each if() statement. You should write it as $n == 3 instead of $n = 3.

Also you're not comparing your results correctly. In line 2 of the script you present, you set $n to be a result set, not the actual result. The actual result would be $n['alias_switch'].

Try this code, if you wish:

<?php
$result = mysql_query("SELECT alias_switch FROM peoplebase");
$n = mysql_fetch_assoc($result);
$alias_switch = $n['alias_switch'];

if($alias_switch == "1") {
    mysql_query("UPDATE peoplebase SET alias_switch='2'");
}
elseif($alias_switch == "2") {
    mysql_query("UPDATE peoplebase SET alias_switch='3'");
}
elseif($alias_switch == "3") {
    mysql_query("UPDATE peoplebase SET alias_switch='1'");
}
RaeesIqbal commented: Thank you,,,, I am such a dumb ass, cant believe i was on this problem from last 1 hour. I'm so happy that i want to kiss your forehead. Thank you +0
minitauros 151 Junior Poster Featured Poster

1 sept 07 - 16 dec 10

I want to find the year numbers. BUT the text might also be something like: 1 sept 2007 - 16 dec 2010, or
sept 2007 - dec 2010
or
09-2007 - 12-2010
or
'07 - '10

and so on.

minitauros 151 Junior Poster Featured Poster

For you maniacs who are interested in the real regex:

/
(
    (?<![\d])[0-9]{4}(?![\d])|['"][0-9]{2}(?![\d])
    |(?:(?:jan|feb|mrt|apr|mei|jun|jul|aug|sept?|okt|nov|dec)[ \t]?['"]?)\d{2}
)                                                                                          # Find first year
\s*
(?:[a-z]+[\s]+|\d{1,3}[\s]+|\d{5,}[\s]+){0,2}                                              # Anything between first year and until part?
(?:tot[ ]en[ ]met|t\/m|\bt[ ]m\b|\btm\b|\btot\b|\?|(?<![A-Za-z])\-(?![A-Za-z]))?           # Find until part (momentarily not required, maybe it should be if any errors ever start occuring?
\s*
(?:[a-z]+[\s]+|[\d\/]{1,3}[\s]+|\d{5,}[\s]+|[\d]{1,3}[\/\-]){0,2}                          # Anything between until part and second year?
(
    (?<![\d])[0-9]{4}(?![\d])|['"][0-9]{2}(?![\d])
    |(?:(?:jan|feb|mrt|apr|mei|jun|jul|aug|sept?|okt|nov|dec)[ \t]?['"]?)\d{2}
)                                                                                          # Find second year
/ixs

I want the first and last year to get returned.

minitauros 151 Junior Poster Featured Poster

Hello there,

I would like to know if anyone knows a solution for excluding a group within a group in a regular expression. For example:

/(name|(?:last[ ])name|(?:first[ ])name)/i

I would only like the word "name" to be returned (this is just an example), but when I take match number 1 (matched against "last name"), I get "last name" instead of just "name", even though I used "?:" in the capture group. I think it's because I didn't use "?:" in the first group, so therefore I would like to know: is it possible to achieve what I would like to achieve?

minitauros 151 Junior Poster Featured Poster

Yea so dont use the window.resize() jQuery function then, but just check the viewport width while the page is being loaded :). And you're welcome!

minitauros 151 Junior Poster Featured Poster

Well does "making it look like it is in a subfolder" not equal "virtually putting it in a subfolder"? ;) This is the only option I know about that works, but I'm curious as to what others think of this.

minitauros 151 Junior Poster Featured Poster

Try using absolute paths to your css files. E.g. not css/stylesheet.css, but /css/stylesheet.css or http://www.yourwebsite.com/css/stylesheet.css

minitauros 151 Junior Poster Featured Poster

So where are you getting these links? Are they the link of the page the user is currently on? Or are you retrieving them from a database or something like that?

For the rest, you could use regular expressions to find the base part of the link. I think something like this should work:

/^https?:\/\/[a-z0-9-.]+/

E.g.:

<?php
$regex = '/^https?:\/\/[a-z0-9\-.]+/';
preg_match($regex, $full_website_url, $matches);
$base_url = $matches[0];

That should return the base part of the website url, for example the "http://www.daniweb.com" part out of "http://www.daniweb.com/web-development/php/threads/451964/change-all-urls-to-absolute".

minitauros 151 Junior Poster Featured Poster

I cannot say with 100% certainty that it works on every browser, but I wouldn't see why it wouldn't :). So yeah, I would consider it safe to use if I were to make a website with a smaller viewport.

minitauros 151 Junior Poster Featured Poster

What exactly is is that you are asking, pdprince? And could you please start a new thread for your problem in which you describe your problem and ask your question? :) That way we can keep each thread limited to one specific question.

minitauros 151 Junior Poster Featured Poster

Have you searched for PHP tutorials? :)

minitauros 151 Junior Poster Featured Poster

Hmmm well I have no better idea then than to write all your functions to an external file each time the list of categories gets changed, and then including that file in each file that you need to use those functions in.

You can write to a file using file_put_contents(), for example. What I'm saying is: generate those functios as you would write them in a new PHP file, and then actually write them to a new (or existing) PHP file.

If anyone has any better ideas, I'd love to hear them. If noone is taking the trouble to read such a long post and my answer is not what you are looking for, I would suggest starting a new topic with the same question :). Hope I could be of help anyway!

minitauros 151 Junior Poster Featured Poster

Yea I may not have used the same variable names as you have. You might want to check the code I provided and change the variable names to whatever variable names you want to use.

minitauros 151 Junior Poster Featured Poster

Oh that looks like a typo ^^. Have you checked out what's on line 156? It says an invalid argument is supplied for the foreach() loop, which is correct, cause we're passing $search_term to it instead of $search_terms (with an "s" at the end). If you correct that, I think it should work :).

minitauros 151 Junior Poster Featured Poster

Ouch, that sounds like the file has not yet finished uploading? :) Or is there something wrong on line 327?

minitauros 151 Junior Poster Featured Poster

I did the following, and that worked. Is that any help or am I still not understanding your problem correctly?

<?php
$function_content = '
    if($arg1 == \'test\')
    {
        echo \'Yes\';
    }
    else
    {
        echo \'No\';
    }
    ';

$function = create_function('$arg1', $function_content);

$function('test'); // Returned "Yes".
$function('testt'); // Returned "No".
minitauros 151 Junior Poster Featured Poster

Ah now we're going somehwere. You could try the following code. If anything is unclear to you, let me know :).

<?php
$search_terms = $_REQUEST['q'];

// Make sure we can do a safe input by applying mysql_real_escape_string.
// Check out the PHP documentation if you want to learn more about array_map().
$search_terms = array_map('mysql_real_escape_string', $search_terms);

if($search_terms)
{
    foreach($search_term as $term)
    {
        // Let's build the WHERE part of the query.

        $where_parts .= '(';
        $where_parts .= ' keywords LIKE "%' . $term . '%" ';
        $where_parts .= ' OR catagories LIKE "%' . $term . '%" '; // For your info, it's "categories", not "catagories" ^^.
        $where_parts .= ' title LIKE "%' . $term . '%" ';
        $where_parts .= ')';
    }

    // Let's implode the where parts to create an actual where clause.
    $where = implode(' OR ', $where_parts); // Change to AND if you want, of course :).

    // Your possible new query could be as follows:
    $q = 'SELECT title, 
            id, 
            keywords, 
            catagories, 
            emurl 
        FROM libvid
        WHERE ' . $where . '
        ORDER BY title DESC';
}
else
{
    //* No search was done.
}
minitauros 151 Junior Poster Featured Poster

Ah I see three queries there, am I right? And does each of those queries return ALL rows from the table specified? Because there seems to be nothing wrong with your queries, although I've personally never seen "IS NOT null" being used at the end of a WHERE statement, but I cannot say with certainty that that is incorrect syntax. You could try and see what happens if you don't add that to the end of your WHERE statement.

If I were you, I wouldn't use so many separate queries. Instead, I would slightly modify my WHERE part to include all the WHERE...LIKE... parts. For example WHERE (... LIKE first word) OR (... LIKE second word) OR (... LIKE third word) etc. Is that clear enough? :)

minitauros 151 Junior Poster Featured Poster

Have you checked out the create_function() function? See here: http://php.net/manual/en/function.create-function.php

minitauros 151 Junior Poster Featured Poster

Well, if you want to search for a match with multiple words, you should probably use WHERE ... LIKE %...% OR ... LIKE %...% (for example).

So, in your example:

WHERE (keywords LIKE '%$word1%' OR catagories LIKE '%$word1%' OR title LIKE '%$word1%')
OR (keywords LIKE '%$word2%' OR catagories LIKE '%$word2%' OR title LIKE '%$word2%')

etc.

To remove the comma's, simply pass an empty parameter to your implode function :). E.g. implode('', $array).

If you need more info, could you please post the exact query that you are using to search for results? So not your code, but the actual query itself, echo'd? :)

minitauros 151 Junior Poster Featured Poster

Usually the value of "href" is included within double quotes. E.g. <a href="http://www.google.com">Google</a>. Have you tried that? :)

minitauros 151 Junior Poster Featured Poster

So exactly what is wrong with your $var at the current moment? Are there comma's where you don't want them? Or are there values that you do not want to be included in $var?

minitauros 151 Junior Poster Featured Poster

Hm this might not be what you're looking for but have you thought about using HTML for that? ;)

For example: <a href="[specify a link]">[specify a title]</a>
Which could become: <a href="website.com/page.php?id=$id">CLICK HERE</a>

minitauros 151 Junior Poster Featured Poster

Also, for the error function, add a parameter (data) to it so that you can see what error is coming back.

What stbuchok says :). Usually when I get an error it's because the specified file cannot be found. Javascript does not always use the same working directory as PHP, so make sure you specify the exact location to the file you want to load from the page you want to load it from. E.g. if you're making an AJAX call from index.php, and the file you're requesting is in a folder, you should include the folders in your "url" parameter.