ShawnCplus 456 Code Monkey Team Colleague

If in the database it says http://www.google.com then the code

echo '<a href="'.$row['website'].'">'.$row['website'].'</a>';

should produce

<a href="http://www.google.com">http://www.google.com</a>

Look at the source (CTRL+U in Firefox) and see if that is what it is producing

ShawnCplus 456 Code Monkey Team Colleague

Personally I've never picked up a book on PHP and I wouldn't really recommend it. Books take too long to update and are most likely contain outdated information by the time they're published. Especially when dealing with the web. There will be no better source of information for you than the web (along with php.net)

ShawnCplus 456 Code Monkey Team Colleague

Hi thnx for replying
ShawnCPlus, using your script am still getting duplicates- all in one line.
Acute- I tried the endoffile as well but is not working.
Not sure what else to try, any more thoughts...
Cheers

For future reference here when you say you tried an example and it didn't work post the code otherwise we don't know what we or you did wrong to fix it. If I had to guess I would say that when you're writing to the file you're not appending a newline.

ShawnCplus 456 Code Monkey Team Colleague

In what way does it "not work". What are the values of the row (what is the exact value of $row['website']

ShawnCplus 456 Code Monkey Team Colleague

Note: This is beating the crap out of the problem and will be SLOW for large files.

$file = file('somefile');
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$Email = $_POST['Email'];

$line_count_pre = count($file);
$content= $FirstName . '|' . $LastName . '|' . $Email;
$file[]=$content;
$line_count_post = count(array_unique($file));
unset($file);
if($line_count_post > $line_count_pre) {
  // write to the file
} else {
  // It is a duplicate
}
ShawnCplus 456 Code Monkey Team Colleague

A) I'm not sure why you don't want to use a session. B) So you're not sending a string too long you could base64encode a json_encoded array and send it through GET.

ie.,

<?php
$some_array = array('blah', 'blah2');
$some_arrayGET = base64_encode(json_encode($some_array));
?>
<a href="somepage?some_array=<?php echo $some_arrayGET ?>">BLAH!</a>

Then on the other side

$some_array = json_decode(base64_decode($_GET['some_array']));

But, as with anything sent over GET (or POST) it can be modified by the user. If you store it in the session it cannot be modified by the user.

ShawnCplus 456 Code Monkey Team Colleague

Actually, 1 and 3 would be combined since the database would be the store for the binary tree. A binary tree works like this

A
        /   \
       B     C
      / \   / \
     D  E  F   G

Where each letter represents a node. Each node has a parent save the top node (A), also called the root. Any node that has a parent but doesn't have children is called a leaf. (In CS trees are upside down if you didn't notice)

en.wikipedia.org/wiki/Binary Tree

ShawnCplus 456 Code Monkey Team Colleague

A few observations:
1. When you post code, you should use [code] tags to have it format properly.
2. You don't need the <html> <head> and <body> statements. PHP takes care of that.
3. $subject on line 16 isn't defined (at least in what you have shown us).
4. The default is that mail doesn't actually get sent from the local (test) environment. It can be done but you will have to make some changes (if you need this, I'm sure that you can find references from an internet search).

heh, I'm not sure what strange auto_prepend_file setting you're using but PHP does NOT automatically insert any HTML tag.

WAMP/XAMP does not come with an SMTP server so you'll have to configure the php.ini file to point to another SMTP server.

And as noted before, you haven't set the $subject variable to anything.

ShawnCplus 456 Code Monkey Team Colleague

Yer go for eather Wamp or Xampp (But NOT PHP 4, the current version is 5.somthing)

Current version is 5.2.9 with 5.3 on the way shortly.

ShawnCplus 456 Code Monkey Team Colleague

Also, as some advice: DON'T INSTALL PHP4

ShawnCplus 456 Code Monkey Team Colleague

Well, my first question would be why disable CTRL+N? That still leaves CTRL+T (new tab in ie7) and it doesn't prevent them from just opening a new instance of IE7 the normal way. I personally despise when people alter my keyboard shortcuts and/or disable things on a site. If you're doing this it usually means you've designed something wrong previously and you're trying to make up for it.

ShawnCplus 456 Code Monkey Team Colleague

An example of how to write a simple rewriting rule:

4 year bump! Drink!

ShawnCplus 456 Code Monkey Team Colleague

It's called AJAX (Let's see if I get berated for saying this this time.)

ShawnCplus 456 Code Monkey Team Colleague

Thanks alot for your help, But Then how can I use it over the net. Because each user will not have that image in directory,

This is just for testing purposes, you can change it back later. If it doesn't find the file with an absolute path then there's something wrong. Also, you're already using an absolute path for the PDF file.

ShawnCplus 456 Code Monkey Team Colleague

No, it means you should give it a path like this C:\somedirectory\img.jpg

ShawnCplus 456 Code Monkey Team Colleague

You could use a CGI script to generate html. There is the cgicc library for building CGI apps that might help.

ShawnCplus 456 Code Monkey Team Colleague

Your problem is just as the exception describes, the file doesn't exist. Try giving an absolute path to the image.

ShawnCplus 456 Code Monkey Team Colleague

In all browsers that's how it is supposed to work. Sessions are saved to cookies which either expire after a certain amount of time or after a user closes their browser. There would be absolutely no way to tell the difference between them opening a new tab or just refreshing the page so you're effectively SOL

darkagn commented: Fast, informed and helpful response +4
ShawnCplus 456 Code Monkey Team Colleague

A) Don't hijack year-old threads, create your own.

B) The escape sequence is a backslash, not a forward slash (\n, NOT /n)

ShawnCplus 456 Code Monkey Team Colleague

If it returns 0 rows but there isn't an error than its just that. Nothing matches the conditions you're giving it. Trying making your condition less specific until you get a result and then narrowing it down again. Ie.,

SELECT ZipCode FROM zips ORDER BY Population DESC LIMIT 5

Then

SELECT ZipCode FROM zips 
  WHERE Latitude BETWEEN '$swlat' AND '$nelat'
  ORDER BY Population DESC LIMIT 5

etc.

ShawnCplus 456 Code Monkey Team Colleague

Does your mysql_query call return 0 rows or does it throw an error?

ShawnCplus 456 Code Monkey Team Colleague

You never end the first if so its waiting for the ending brace. And what I meant was that <meta> tags go in <head> in the document

ShawnCplus 456 Code Monkey Team Colleague

Is it a requirement that you code all of the AJAX library by hand. If not you might want to take a look at jQuery. Otherwise, what is the error you're getting.

ShawnCplus 456 Code Monkey Team Colleague

There might be something in includes/footer.php that's doing it. As a side note a meta refresh tag goes in the head section, not the body.

Post the entirety of the code so I can at least run it through phplint to see if there are syntax errors :)

ShawnCplus 456 Code Monkey Team Colleague

that's way over-complicated the function. You don't need to pass the form and you don't need if-blocks

function validate()
{
  return confirm("Are you sure to delete these details from database?");
}
ShawnCplus 456 Code Monkey Team Colleague

heh, I guess I'm just not understand how you're not getting it. You can do 4 + 0 = 4 and you can do 0 + 4 = 4 but for some reason you can't do 2 + 2 = 4. You have the two pieces of the puzzle, you're just not putting them together.

Set the cookie

$some_array = array('Hello' => 'World');
setcookie('some_cookie', serialize($some_array), time() +3600);

Retrieve the cookie

$some_array = unserialize($_COOKIE['some_cookie']);
ShawnCplus 456 Code Monkey Team Colleague

Firstly, I hope the "mrs." was unintentional. Secondly, probably the cleanest way to write it is

<?php include("viewworkout.php") ?>
<script type="text/javascript">
  var numrecords =  <?php echo $numrows ?>;
  var muscle = new Array();
  var exercise = new Array();
  var set = new Array();
  var weight = new Array();
  var reps = new Array();
  var difficulty = new Array();
<?php for($i = 0; $i < $numrows; $i++): ?>
  var muscle[<?php echo $i ?>] = "<?php echo $muscle[$i] ?>";
<?php endfor ?>
</script>
ShawnCplus 456 Code Monkey Team Colleague

That is correct, you're not lost. You get

a:3:{s:5:"apple";s:5:"green";s:6:"orange";s:6:"orange";s:6:"banana";s:6:"yellow";}

from print serialize($data); and you get Array from echo $next As a side note, don't mix echo and print, there's no reason to, they do the same thing.

ShawnCplus 456 Code Monkey Team Colleague

use serialize and unserialize instead of implode/explode

ShawnCplus 456 Code Monkey Team Colleague

What do you mean? rows/cols attributes work the same as far as I know

ShawnCplus 456 Code Monkey Team Colleague

If you know how to set and get data from the cookie I just gave you how to use implode/explode, just put them together. You already did the first part in your original post.

ShawnCplus 456 Code Monkey Team Colleague

Thanks
but I am not sure on how to get the data back out of the cookie.

Then you didn't read the link I posted :)

ShawnCplus 456 Code Monkey Team Colleague

Your script is ok! Try to apply the following format and see how it works:

<?php
echo '<script type="text/javascript">';

include 'workout.php';
echo 'var numrecords = '.$numrows.';';

print "var muscle = [];\n
var exercise = [];\n

</script>"; // so on...
?>

A) Why are you mixing echo and print?
B) His code was cleaner before, don't put HTML in PHP strings, its ugly and unmaintainable

ShawnCplus 456 Code Monkey Team Colleague

Well, firstly, for all that is good in the world, please, please stop using @. Secondly, you already have pid, why assign it again?

ShawnCplus 456 Code Monkey Team Colleague

Well you did it in your example. All I did was explain the correct syntax for implode/explode. Also, see www.php.net/cookies

ShawnCplus 456 Code Monkey Team Colleague

Well if you want to implode the values and store it in the cookie then you'd explode it to retrieve it as an array.

$array = array('orange', 'green', 'blue');
$string = implode(',', $array); // 'orange,green,blue'
$second_array = explode(',', $string); // array('orange', 'green', 'blue');
ShawnCplus 456 Code Monkey Team Colleague

Well what line is the debugger telling you the error is on?

ShawnCplus 456 Code Monkey Team Colleague

HAH Copied/pasted all that for nothing LOL

showvids.php

<?php echo $_POST['channel_name'];?>

As you can see from my previous post there is no data called channel_name . Your select box is named videos_channel .

There is only button , chan_sel , and videos_channel

ShawnCplus 456 Code Monkey Team Colleague

I actually meant show the source of showvids.php. There's nothing that I can see wrong with videos.php (aside from the while/do-while fix).

The following data is being sent to showvids.php if I select Conversations with Swami Satyanada

button          Go
chan_sel        videos_channel
videos_channel  Conversations with Swami Satyananda

So the page is working correctly, its showvids.php that's failing.

ShawnCplus 456 Code Monkey Team Colleague

Firstly, your loop should be a while, not a do-while. (A do-while will always run at least once even if your condition fails which you don't want).

Secondly, would you post your code that's handling the POST. All we see now is your form.

ShawnCplus 456 Code Monkey Team Colleague

That's just about as vague a question one could ask. What about mail servers?

ShawnCplus 456 Code Monkey Team Colleague

Since you're not adding the draggable behavior until someone clicks on it you won't be able to actually drag it until you release and click again.

Place the .draggable() call in your $(document).ready() function. You don't need to explicitly trigger the event either. That's what the draggable behavior does.

ShawnCplus 456 Code Monkey Team Colleague

I agree. The tool does not make you good at using it. However, IDE's and editors that provide functionality such as syntax highlighting, etc. are a net positive in productivity for development, especially for large projects. Knowing some of an API (you certainly aren't going to know all of them) by heart doesn't make you a good developer either. If productivity is your main goal, intentionally not using tools that increase it just because you consider them a crutch is ridiculous. As a developer, my employer is much more concerned with how much quality work I can get done rather than how I would fare on a pop quiz on the order of parameters for some random method in some API.
I too have used Notepad to edit code before. I certainly wouldn't argue that it can edit text and will do for a quick change or in a pinch. I highly doubt you are going to argue that it is your preferred tool for writing code and that is the whole point of this thread. I think everyone already knew that any simple text editor could be used. So really it's a question of which editor do you prefer for PHP? Which has features that you find useful and add to your productivity? That's much more germane here than another "bah, a real coder just uses a text editor!" speech.

Heh, we've driven so far off the OP's question we're on a different continent here. The original question …

ShawnCplus 456 Code Monkey Team Colleague

Some companies will let you use your platform or IDE of your choice, other doesn't. Some software factories in Argentina aren't well equipped or better than India or Pakistan ones. Old computers running a buggy and sluggish outdated version of Eclipse, with spyware, keyloggers, testing code over old and overloaded instances of Tomcat on servers with a nice trade mark (and some spider web dissimulated), you don't want to know what are happening outsourcing to third-world :)
Work environment doesn't make you justice but you can be good indeed, using any IDE.

It seems small but if a company didn't allow me to use my editor of choice I probably would choose not to work there.

ShawnCplus 456 Code Monkey Team Colleague

I visited some clients on-site and the only resource was only notepad. Notepad is installed on every computer, works every time, some quick changes on the code and done! Notepad is faithful.

Get a thumbdrive and install an editor on there, the same excuse can be made for pretty much anything now that ubiquity is moot.

ShawnCplus 456 Code Monkey Team Colleague

Notepad or TextEdit, faster, drag&drop of text, really easy to use.

Chisel/Stone is better than Notepad. Please don't use Notepad

ShawnCplus 456 Code Monkey Team Colleague

There aren't any drag&drop IDEs for PHP that I know of since PHP itself never touches the front end. Zend Studio is probably one of the best out there (You can download a free version though there is a paid version), there's also the PDT project which is a extension onto Eclipse (Much like Zend Studio)

If I could make a recommendation I would shy away from any editor that does everything for you. You don't actually learn the language if you use an IDE that holds your hand the entire time. In the end if you are somehow left without the IDE you are crippled as a developer since you don't know how to use it otherwise which is a huge problem with PHP.

ShawnCplus 456 Code Monkey Team Colleague

Not to be rude but I didn't say print, I said var_dump. That tells you the type along with the value so you would see.
boolean(true)
or
boolean(false)

ShawnCplus 456 Code Monkey Team Colleague

Yes. It should return boolean false. What are you getting instead? What is the output of:

var_dump(EW_IS_WINDOWS);
ShawnCplus 456 Code Monkey Team Colleague

If you're trying to modify an already existing row take a look at
UPDATE which can take a WHERE clause
http://dev.mysql.com/doc/refman/5.0/en/update.html

There is also REPLACE. It acts like INSERT but if a row exists with the same primary key, it will replace it.

IE.,

INSERT INTO sometable (id, name) VALUES (0, 'Shawn');

Will give you the table

ID         Name
0          Shawn
REPLACE INTO someTable (id, name) VALUES (0, 'Tester');

You now have

ID         Name
0          Tester

http://dev.mysql.com/doc/refman/5.0/en/replace.html