ShawnCplus 456 Code Monkey Team Colleague

Is your select inside the <form> tag, and do a var_dump($_POST); to see the values of everything passed from the form

ShawnCplus 456 Code Monkey Team Colleague

Interesting - @ Shawn - what happens if somebody is working on a record and then goes away / closes the computer without saving? Will the db value still have 1 in the locked column? Sorry - I'm messing with table locking at the moment and looking for a 'simple' method myself.

Implementing a timer wouldn't be too hard, setting it to the same length as the session timeout would be the most straightforward way.

ShawnCplus 456 Code Monkey Team Colleague

I understand. So, how do you think user 25's data will be temporarily saved while user 23 does their thing?

Likewise, how will 23's data be saved temporarily is 25 gets in first?

I just started to read about PHP Sessions. Won't PHP Sessions take care of this issue?

It wouldn't be temporarily saved, they'd have to wait until it's unlocked and redo their modifications.

If you're not using sessions already how are you handling user authentication or is it just open to the whole world?

ShawnCplus 456 Code Monkey Team Colleague

Isn't there a difference between locking a database and locking a variable? And if so, how will locking a record keep another user from redefining the first users input variable a split second before it's inserted into a database??

Part A) You're not actually locking the database, you're soft-locking, ie., setting a field on a row saying that it is currently in use.

Step 1: User 23 goes to edit Test4
----------------------
id | name  | locked
----------------------
5  | Test4 | 23        <-- Locked by user 23
----------------------

Step 2: User 25 goes to edit Test4
Error: Test4 is currently being edited blah blah

Step 3: User 23 saves Test4 and leaves the page
----------------------
id | name  | locked
----------------------
5  | Test4 | 0         <-- Unlocked
----------------------

Step 4: User 25 goes to edit Test4
----------------------
id | name  | locked
----------------------
5  | Test4 | 25        <-- Locked by user 25
----------------------

Part B) Locking the record keeps the other user from redefining it because you check for a lock before saving, if it's locked you don't save and you alert the user that it is locked.

ShawnCplus 456 Code Monkey Team Colleague

Sorry VD - I'm no great shakes, but I notice that you are making an amazing contribution at the moment with so many replies - well done! It's just that I've been there and done it with some of these questions - I've had the number of records != max id number in table problem and was stuck for hours trying to figure it out. However, I think there may be an even more sophisticated way of doing it.

I'm not sure that RAND() is truly random - more a quick and dirty randomizer *I think*.

There's no such thing as truly random when it comes to the implementations in PHP or MySQL, it'll always be pseudorandom

ShawnCplus 456 Code Monkey Team Colleague

Thanks. Except, my question has more to do with the simultaneous use of variables. How can a scripter avoid a situation where the first user's input get redefined by a second user before the first user's data gets saved to a database?

Actually that's the problem i was solving. Unless you're constantly forcing the user to update while they are editing (obtrusive) they're always going to have old data. The only way to prevent them from modifying old data after someone else updated is to implement locking.

ShawnCplus 456 Code Monkey Team Colleague

Well as an example if you're using a database you can add a column to the table you're dealing with called "locked" that is set to the editing user's ID when they open the form, then set back to 0 when that same person saves it. If someone with a different user ID tries to save or open it will block them.

ShawnCplus 456 Code Monkey Team Colleague

If the javascript is already on a PHP page then you can just do

var postID = <?php echo $_GET['postID']; ?>

And keep the rest of your code the same.

ShawnCplus 456 Code Monkey Team Colleague

how are you all
I want to write a program where when i enter the number
For example 10
must give the numbers of Singles
1, 3, 5, 7 and 9

please its important

What do you have so far? We're not going to help you if you don't show effort.

ShawnCplus 456 Code Monkey Team Colleague

Get firebug and use Firefox. (getfirebug.com and getfirefox.com) read through the Firebug site on how to use it.

ShawnCplus 456 Code Monkey Team Colleague

hey ardav! you always contradict at my every post! grrr....! :@

Well, ardav is correct so he is completely within his right to make a post :)

ShawnCplus 456 Code Monkey Team Colleague

I believe you're referring to the controls that look sort of like

.---.   .---.
     | + |   | + |
     '---'   '---'
.---..---.   .---.
| + || 2 |   | 1 |
'---''---' . '---'
     .---.   .---.
     | - |   | - |
     '---'   '---'

You could certainly make your own using Javascript or you could take a look around Google for Pastrykit which is a Javascript framework for iPhone web development to mimic its UI

ShawnCplus 456 Code Monkey Team Colleague

If you want to prevent the user from modifying it on the front end you could do as you suggested: Have the timer on the front end (Javascript) but also validate the start and end times on the server. Using both methods would be the way to go. Any time you're expecting input from the user (even if it's just time) always validate on both sides.

ShawnCplus 456 Code Monkey Team Colleague

The thing you are describing is not a framework, it's an ORM. Google around for simple PHP ORMs and you'll find what you are looking for. If you look for framework it's just going to be, exactly like you said, a bunch of stuff you don't need.

My best recommendation for an ORM is Doctrine but that is far from lightweight. It is a very mature, very powerful PHP ORM

ShawnCplus 456 Code Monkey Team Colleague

u forget to show the code... well based in your problem i think its because you didn't escaped the singe quotes (') in the sentece. coz. single qoutes has meaning in PHP so they should be escaped. i think this may be your code

<?php echo "10 Facts about World's Tallest Building"; ?>

. you must escape the single quote inside your sentence to something like this.

<?php echo "10 Facts about World\'s Tallest Building"; ?>

If you're using " then you need to escape with \". Likewise, if you're using ' you need to escape with \'. But you don't need to escape if you're using the opposite ie., "this is ' fine" , ' this is " fine' , " this is " broken" , ' this is also' broken'

ShawnCplus 456 Code Monkey Team Colleague

Why are you using such an old version of MySQL with the new version of PHP? And does that file actually exist in that directory?

ShawnCplus 456 Code Monkey Team Colleague

Might want to actually show your code, explaining it helps but seeing your code is much more helpful. And the yield operator is used for generator-iterators not AJAX.

ShawnCplus 456 Code Monkey Team Colleague

It can already act like an array
Dot Operator

var someObject = {
  someProp : 9,
  someFunc : function () { return this.someProp; }
};
alert(someObject.someFunc()); // 9

Array Accessor

var someObject = {
  someProp : 9,
  someFunc : function () { return this['someProp']; }
};
alert(someObject.someFunc()); // 9

Both act exactly the same.

ShawnCplus 456 Code Monkey Team Colleague

Abstract classes are nice in that they aren't full implementations of objects but prototypes of them. So take this bad example.... for example: You have want to have Objects and you want all Objects to have an Identify method but each Object will do something different.

abstract class Object
{
  protected $name = 'Object';
  abstract protected function identify();
  protected function __toString()
  {
    return $this->name;
  }
}
class Square extends Object
{
  // PHP Fatal, class Square doesn't implement required method identify
}
class Square extends Object
{
  protected $name = 'Square';
  protected function identify()
  {
    return 'I am a Square';
  }
}
$square = new Square();
echo $square->identify(); // implementation of abstract method
echo $square; // Inherited implementation of Object::__toString
ShawnCplus 456 Code Monkey Team Colleague

.db files are usually associated with SQLite, so go download it and use it to open it. In the future don't post massive blocks of text like that. It's not fun having to scroll for an hour.

ShawnCplus 456 Code Monkey Team Colleague

You don't need the leading "'" . when setting $sides and $totals.

ShawnCplus 456 Code Monkey Team Colleague

\ is the escape character, not /

ShawnCplus 456 Code Monkey Team Colleague
}else{
   print($con->error);
}
ShawnCplus 456 Code Monkey Team Colleague
ShawnCplus 456 Code Monkey Team Colleague
ShawnCplus 456 Code Monkey Team Colleague

My guess is that you're using it as a GET parameter and it's being encoded to it's respective URL entity

ShawnCplus 456 Code Monkey Team Colleague

Writing Extensions: http://devzone.zend.com/article/1021

If you're changing the actually internal PHP code you will have to compile every time. That's how compiled languages work :P

ShawnCplus 456 Code Monkey Team Colleague

It's really up to you and which you like working with more. Django's closest PHP analogue would probably be Symfony since they share a lot of the same methodologies (helper functions, plugins, MVC model, ORM usage, etc.)

ShawnCplus 456 Code Monkey Team Colleague

OK, that all makes perfect sense.
However, if the PHP code is meant to be echoed and stored into a JS variable, where is the PHP value stored until the onload JS function executes?

It's not stored anywhere, it will always exist in the JS as far as the browser knows.

Example (Both of these are exactly the same as far as the browser is concerned):

<?php $somestring = "Hello"; ?>
<script type="text/javascript">
alert("<?php echo $somestring; ?>");
</script>

When the above hits the user they get this: (Go ahead, view the source of the page, you will see this. You'll never see PHP in the source of the page since it's not the client (browser) that's executing the PHP code)

<script type="text/javascript">
alert("Hello");
</script>
ShawnCplus 456 Code Monkey Team Colleague

If you have that code on a php page then it will try to call the function and insert the output directly into that string. You have to understand the difference between a server-side language and a client-side language. PHP will get executed before the javascript even hits the browser.

Example:
What you code in somepage.php

<?php
// this stuff never touches the browser
?>
<script type="text/javascript">
alert("<?php echo 'Hello World!'; ?>");
</script>

When the page gets to the user there is no longer any PHP code in the page, the server has already interpreted it and given the results so the browser receives

<script type="text/javascript">
alert("Hello World!");
</script>
ShawnCplus 456 Code Monkey Team Colleague

JS has absolutely no clue that PHP is even being called since the PHP code is evaluated before the page gets to the user and the Javascript isn't evaluated until _after_ the page gets to the user so there is a different issue

ShawnCplus 456 Code Monkey Team Colleague

You shouldn't be using session_register or session_is_registered anyway, take a look at the PHP documentation.
http://php.net/session_is_registered

ShawnCplus 456 Code Monkey Team Colleague

You forgot the grouping parens

somestring.replace(/(^\s*|\s*$)/g, "")
ShawnCplus 456 Code Monkey Team Colleague

a header() call does not end the script. Always place exit; after a header() call if you don't want anything else to execute after it.

// do some stuff
header('Location: blah.php');
// this stuff gets executed too
header('Location: blah2.php'); // user is now redirected to blah2.php
exit;
// this stuff doesn't get executed
header('Location: blah3.php'); // never gets here, the user already left the page
ShawnCplus 456 Code Monkey Team Colleague

do you have display_errors set to On?

ShawnCplus 456 Code Monkey Team Colleague

Also put

ini_set('display_errors', 'On');

Below error_reporting(E_ALL);
If you still don't see any errors it could be because you're trying to call a function which obviously does not exist ( XYZDBConnect() )

ShawnCplus 456 Code Monkey Team Colleague

Hi..

I paced the 'error_reporting(E_ALL);' ... but couldn't find the FAQ that you were saying about...

After you placed that in the code refresh the page. Instead of a white page you should see errors. If you get errors that mention something about a MySQL result resource follow the FAQ. If it is a different error post the error here.

ShawnCplus 456 Code Monkey Team Colleague

Right below # BEGIN SCRIPT place

error_reporting(E_ALL);

Then follow the FAQ on the main page of the PHP forums

ShawnCplus 456 Code Monkey Team Colleague

Show us the source of the page

ShawnCplus 456 Code Monkey Team Colleague

Just go to the page in the browser, the same way you would locally except replace localhost with the domain name.

ShawnCplus 456 Code Monkey Team Colleague

I use (g)Vim 7.2, no "IDE" comes close to how powerful it is :)

jQuery for small JS projects(Extremely well built, huge community, excellent documentation), Ext for large JS projects (same reasons). I don't tend to use many pre-built PHP libraries save Doctrine.

When I used a framework I used Symfony

ShawnCplus 456 Code Monkey Team Colleague

I meant the Javascript code that is handling the response FROM the servlet. Not the Java code that is providing the response.

ShawnCplus 456 Code Monkey Team Colleague

Post the code that handles the response from the servlet.

ShawnCplus 456 Code Monkey Team Colleague

use print_r or var_dump.

ShawnCplus 456 Code Monkey Team Colleague

You haven't shown any code so the best I can do is give a short example:

class someClassA
{
  public function someMethodA()
  {
    throw new Exception("Error");
  }
}

class someClassB
{
  public function someMethodB()
  {
    $someInstA = new someClassA();
    try
    {
      $someInstA->someMethodA();
    }
    catch (Exception $e)
    {
      echo $e->getMessage();
    }
  }
}
ShawnCplus 456 Code Monkey Team Colleague

I think I understand what you were trying to say:

var ids = [];
$('#rightList > li').each(function(el) {
  ids.push(el.id);
});
peter_budo commented: Very helpful reply +12
Atli commented: Perfect answer :) +3
ShawnCplus 456 Code Monkey Team Colleague

You forgot the echo

vart pt = <?php echo json_encode($prt); ?>
ShawnCplus 456 Code Monkey Team Colleague

jQuery is actually one of the simplest Javascript libraries around. It's important to know at least a one be it jQuery or Prototype or Mootools, etc. The reason those libraries exist is to save you time and effort.

ShawnCplus 456 Code Monkey Team Colleague

Well that only applied to the document.querySelector part. jQuery supports pretty much every modern browser. http://jquery.com

ShawnCplus 456 Code Monkey Team Colleague

in Firefox you can use the built-in document.querySelector and document.querySelectorAll which use CSS selectors to find DOM elements. Similarly using the jQuery library you can do things like

$('#somediv > p') // returns all p tags that are children of a div with the ID of somediv