Will Gresham 81 Master Poster

Lines 24+27: You don't use a comma to concatenate a string.

Actually, you can in an echo.
echo is a language construct, and can take multiple arguments. If you want to get down to micro seconds, it is also slower to use concatenation in an echo instead of comma separated values..

Will Gresham 81 Master Poster

It might help to post some code, but the most likely reason is an error with the callback function in your ajax call.

Will Gresham 81 Master Poster

fopen gives you a handle to a file, you then need to use another function (Such as fwrite, fputcsv...) to put data into the file.

Will Gresham 81 Master Poster

You don't need MySQL to store data in a CSV, if you are using CSV for storing data rather than reporting on or exporting data, then I would have to wonder why you aren't just storing it in MySQL.

The function you need is fputcsv, plently of examples on google.

Will Gresham 81 Master Poster

You can set the order that the data comes in your query, example MySQL:

SELECT *
FROM `table`
WHERE `column` = "value"
ORDER BY `column` ASC
Will Gresham 81 Master Poster

Blindly copying $_POST variables into $_SESSION variables is doing nothing different than your first script.

At the very minimum you should be doing a isset() check on them to see if they contain any data before assigning the session variable. That way you won't be overwriting the session contents with null values.

Alternatively, use $_REQUEST to fetch the values, and in any links you create add the key value pairs you need to the query string.

Will Gresham 81 Master Poster

Generally speaking, you should not (as a web developer) be attempting to alter the browser functionality.

There are very few cases where this should be considered acceptable.

If you are interested in the javascript, a very quick Google search will tell you what you need to know.

Ezzaral commented: Agreed. +14
Will Gresham 81 Master Poster

If by control key you mean the key on the keyboard, you cannot with PHP.

While it is possible to disable keys using Javascript, the user turning off Javascript would render this useless.

Why would you want to disable a key anyway?

Will Gresham 81 Master Poster
Will Gresham 81 Master Poster

Check the braces, your || is not within them.

Will Gresham 81 Master Poster

Change

<tr><div class=\"divider\"></div></tr>

to

<tr><td colspan=\"3\"><div class=\"divider\"></div></td></tr>
Will Gresham 81 Master Poster

Make sure that ldap is enabled in your php.ini file.

Will Gresham 81 Master Poster

Take a close look at this line:

#
if ($_POST['Alumnos'] empty($_POST['Maestros']) empty($_POST['Admins')])) {
Will Gresham 81 Master Poster

See the problem with this line?

if($result)
Will Gresham 81 Master Poster

The reason this does not work will be clear when you read the mysql_query page at php.net.

Here is what it says:

Description:
resource msql_query ( string $query [, resource $link_identifier ] )

And then goes on to say:

link_identifier
The mSQL connection. If not specified, the last link opened by msql_connect() is assumed. If no such link is found, the function will try to establish a link as if msql_connect() was called, and use it.

You are using the mysql_select_db value in the query, it is expecting the result from mysql_connect.

To simplify things, if you only make 1 connection to MySQL, then you can omit this parameter altogether.

Will Gresham 81 Master Poster

You can try counting the number of values in the table, if this is 0 then there are no entries.

Your mysql_query should contain something similar to this:

SELECT count(*) FROM `table_name`
Will Gresham 81 Master Poster

Personally, I use something along the lines of the following:

$salt = sha1(md5($_POST['password']));
$password = md5($_POST['password'].$salt);

Using strings such as username or user id is not a good idea as these will be known by anyone using the site, but using the password means that it is unique for each user without having to save the sale string anywhere.

Also, providing you salt the password, then MD5 should be fine :)

Will Gresham 81 Master Poster

Add the onclick event to the element containing the text.

Will Gresham 81 Master Poster

Try something like this:

<form>
<input id="foo" type="text" />
</form>
<div id="bar" onclick="populate(this);">
value for the div
</div>

JS:

function populate(el) {
document.getElementById('foo').value= document.getElementById(el.id).firstChild.nodeValue;
}
Will Gresham 81 Master Poster

To set the value of the textbox, use .value, not .innerHTML

Will Gresham 81 Master Poster

Try using like instead of = in the query.

$result = mysql_query("SELECT * FROM `some_table` WHERE `some_column` like '%some_value%'");

I was beaten by the post above :), that suggestion takes into account the commas too.

My suggestion will match anything with that number in, so if $test was 4 then it would also pull 42, 143, 204 etc..

Will Gresham 81 Master Poster

.I think it's not connecting to the database, as we added a couple echo statements that should tell me if if got to the db, then to the table. It doesn't print them, so I guess that's the first problem.

Would you mind posting said code here for review?

We are happy to help, but we are not here to spoon feed you code.

You will learn more from having mistakes corrected than just being told the answer.

Will Gresham 81 Master Poster

Your syntax is incorrect.

Try this:

if (mysql_num_rows($result) > 0) {
  $row = mysql_fetch_assoc($result);	
  while ($row = mysql_fetch_assoc($result)) {
    print_r($row);
  }
}
Will Gresham 81 Master Poster

No extraction required, just count $_POST['label'] :)

josephe commented: Thank you so much!! +1
Will Gresham 81 Master Poster
Will Gresham 81 Master Poster

Make sure you have PHP installed from www.php.net otherwise the server will treat the php file as any other unknown file and ask to download it.

Will Gresham 81 Master Poster

Ah, whoops, wrong brackets as well. Missed that on your first post :P

For functions, use standard braces ( and ).

Curly braces are for statements and function definitions.

So it should be substr($_REQUEST['cc_number'] , -1, 4)

drewpark88 commented: Will is awesome, helped a bunch! +1
Will Gresham 81 Master Poster

Almost right., the -4 needs to be -1 though.

A positive number will start from beginning of the string and return the number of characters specified, while a negative number to start from end of string.

In this case, you want to start with the last character(-1) and read 4 characters :)

Will Gresham 81 Master Poster

It might be helpful to post the actual code you used when you got the error.

Will Gresham 81 Master Poster

May help to post some more of your code.

But I assume you are running an empty() check on the POST vars?
From the PHP manual:

Returns FALSE if var  has a non-empty and non-zero value.

The following things are considered to be empty:

    * "" (an empty string)
    * 0 (0 as an integer)
    * "0" (0 as a string)
    * NULL
    * FALSE
    * array() (an empty array)
    * var $var; (a variable declared, but without a value in a class)

I would say in this case possibly use the isset() instead, this will return false on a NULL value, rather than a 0.

Otherwise, post the code so we can look.

Will Gresham 81 Master Poster

What is going on with these lines?

z-index:3;

then

>?php


info


?>

Doesn't really look right.
You have not closed the <style type="text/css"> or <!-- , you are missing a } to indicate that you have finished the styles for #footer and PHP is opened with <?php not >?php I also have no idea why you have a random then and info in there either...

Will Gresham 81 Master Poster

That's what we are here for :P :D

Don't forget to mark as solved.

Will Gresham 81 Master Poster

Instead of putting a password hash in the URL (Not a very good idea) why not generate a random string when the user is created and just put this (and possibly the username) in the URL.

Then, check that the string in the URL matches the one in the database when they visit the page.

Will Gresham 81 Master Poster

Is the '$_SESSION' value set?

Change your query to this:

$result = mysql_query($query,$con)or die("Error: " . mysql_error());

Does it output any errors with that in place?

Will Gresham 81 Master Poster

Your write function has a name which looks familiar.

Try not to use names of actual JavaScript functions.
What is happening is that you are saying:

onclick="write(document.getElementById('words').getAttribute('value'));" >

Which is doing the same as if you have put:

onclick="document.write(document.getElementById('words').getAttribute('value'));" >

See the problem?

Will Gresham 81 Master Poster

What code are you using at the moment and what errors (if any) does it return?

Will Gresham 81 Master Poster

The easiest way would be using an API if the owners of the other site have that option.

Otherwise as you said cURL is a good starting point.

Finally, you could try 'Screen Scraping' (again, cURL) to get the source code from a rendered page and pull the information you need.

Will Gresham 81 Master Poster

This is not a PHP function. It is likely that you have an included file or code somewhere which defines this.

Will Gresham 81 Master Poster

I use the same password for everything (nearly everything anyway) it contains part of the WPA2 key for my router, part of the phone number at my previous address and part of my name :P

It is not a dictionary word, is 16 characters long has a mix of alphanumeric characters and symbols, so I would like to think it is fairly secure :)

Will Gresham 81 Master Poster

The $_SESSION variable is an array anyway, so no need to declare it as an array.

A few slight errors in your code though, look through the below and comments:

session_start();
      $rand = mt_rand(0, count($files));
      while(in_array($rand,$_SESSION['rand_img'])) {
        $rand = mt_rand(0, count($files));
      }
      // Check if the array has 50 indexes, and remove the first index if it does
      if(count($_SESSION['rand_img']) >= 50) {
        $removed = array_shift($_SESSION['rand_img']);
      }
      // No need for $i, [] will insert the $rand in the next location.
      $_SESSION['rand_img'][] = $rand;
   }

That should work, but I have not tested it, but hopefully you get the general idea..

Will Gresham 81 Master Poster

Providing you clean up after yourself with session_destroy(); you shouldn't have too many issues. Sessions are small files :)

Will Gresham 81 Master Poster

Use a session to store the $rand value for the last x images:

$_SESSION['rand_img'][] = $rand;

You could add in an if to that to remove the first item of the array once 50 items are stored.

Then, use the In array function to see if the rand number generated is in the session and regenerate if it has been seen in the last x times.

Will Gresham 81 Master Poster

That will remove any preceding or trailing white space from the string.

Also, you may want to phrase your initial question better :P You asked for a script to add a space 'after every 4 digits' which is what you got..
\w will match a-z, A-Z, 0-9 and underscores, so yes, replacing the d with a w should work if you want a space inserted after every 4 characters.

Will Gresham 81 Master Poster

If you echo $dest what does it say?

Will Gresham 81 Master Poster

hi, I have tried both

$image_name = date('$dest' 'Ymdhis') . "." . $image_ext[1];

//and i have tried this 

$image_name = date('uploaded/' 'Ymdhis') . "." . $image_ext[1];

but i get an error all the time ??

Perhaps you should take another look at the Date function..

Will Gresham 81 Master Poster

Surely you would want to use the value of $dest to store the file location in the DB..

Will Gresham 81 Master Poster

Apparently this server has a mind of it's own :P

Allsorts of fun with subscription emails being duplicated and other bits :D

Will Gresham 81 Master Poster

First problem with your script, you are missing a ; on line 24.
Second problem, you haven't created a var called xtra which you try to use on line 31.

Also, why are you mixing DOM standard with innerHTML?

Lastly, this appears to be JavaScript, not PHP. For future reference, there is a JS forum here: Click.

Will Gresham 81 Master Poster

Why not have 1 file with the PHP script to make the links, then use an include() function on each of the pages.

Will Gresham 81 Master Poster

When I come to DW I have the C++ forum bookmarked. So the first thing I do is look at the threads in that forum to see if I need to reply to any of them (via the New button). Then I'd use the Favorite Forums links to do the same with the other favorite forums. In the 4+ years that I have been a member here I think I may have visited the DW Home page 5 or fewer times.

Practically the same for me, but for the PHP forum.

Also +1 to Sknakes point, I look at the HTML and CSS & Site Layout often, and that is 2 layers.. not a huge difference in the amount of time to get there, but it was so much easier when they were always on the right.

I also rarely view the homepage, had to go look just now to actually remember what is on there (I can see why it is useful, but personally I have no use for a list of topics from all forums), I almost always enter the site from a bookmark to PHP or Geeks Lounge, if not then its from history.