ShawnCplus 456 Code Monkey Team Colleague

Actually that's accomplished quite easily with a little Apache voodoo known as ModRewrite. Lets say you are using the fake directory app

RewriteEngine On
RewriteRule ^app/(.*)/?$ /index.php?app=$1

Place that in the .htaccess file and it will be completely transparent to the user.

ShawnCplus 456 Code Monkey Team Colleague

If nl2br isn't working for you the wordwrap function might

ShawnCplus 456 Code Monkey Team Colleague

Don't format their input when they enter it. Format it on output. And since you aren't showing the html/css of where it's getting displayed I can't help you fix that part.

ShawnCplus 456 Code Monkey Team Colleague

The function is called nl2br That will turn all newlines into HTML linebreaks.

Example:

$Input = "Testing
This is on a new line";
echo nl2br($Input);

Output

Testing<br />
This is on a new line
ShawnCplus 456 Code Monkey Team Colleague

You can use something called a variable variable(yeah, I know it's weird)

$variable="name";
$$variable = "Shawn";
echo $name; // prints Shawn
ShawnCplus 456 Code Monkey Team Colleague

Query strings are used when you need to send data through the URL.

<a href="somePage.php?first_name=Foo&last_name=Barr">Barr, Foo</a>

When a user clicks on that link it will send them to the page somePage.php with the following data.

first_name = Foo
last_name = Barr

The first variable is appended to the url with ?<variable name>=<value>. Any additional variables are appended with an ampersand, ie., somePage.php?var1=blah&var2=blah2 Hope that helps.

ShawnCplus 456 Code Monkey Team Colleague

You set the form's action to <?php echo $_SERVER['PHP_SELF'] ?> . The page will post back to itself.

ShawnCplus 456 Code Monkey Team Colleague

I'm pretty sure it has to be surrounded with quotes, ie.,

SELECT first,last, number from friend WHERE id IN ('1','2','3','4')
ShawnCplus 456 Code Monkey Team Colleague

What you're looking to get is the hostname, not the IP. http://us.php.net/manual/en/function.gethostbyaddr.php

ShawnCplus 456 Code Monkey Team Colleague

You don't need a database to use Ajax. Ajax's purpose is to allow you to send asynchronous requests to a separate page and handle that request (hence the name). You can, if you want, make a request to a page which interacts with the database but Ajax itself shouldn't really interact with the database for security reasons.

ShawnCplus 456 Code Monkey Team Colleague

OK, there is another post that deals with almost the exact same topic. You can't use relative links in emails. The recipient's email client doesn't know what or where resetPassword.php is, nor does it know where 'images/emailNotGone.png' is. You have to use absolute links, ie., http://www.example.com/resetPassword.php

ShawnCplus 456 Code Monkey Team Colleague

The div should look like this if you want it to be hidden in the first place.

<div id="testDiv" style='visibility:hidden'>
ShawnCplus 456 Code Monkey Team Colleague

OK, exactly what part isn't working. Please describe your problem

ShawnCplus 456 Code Monkey Team Colleague
if (isset($_COOKIE['$Username']))
    $visits = $_COOKIE['$Username'];

Never works because variables in single quotes ', aren't parsed. You need double quotes, ie.,

if (isset($_COOKIE["$Username"]))
    $visits = $_COOKIE["$Username"];

You have to do that for all of those variables in there.

ShawnCplus 456 Code Monkey Team Colleague

selectbox.options is an array. The add() function is a member of the Element family ie., selectbox.add(<elem>); not selectbox.options.add(<elem>);

ShawnCplus 456 Code Monkey Team Colleague

Not unless you have software running on their system. Even if you did I could probably guarantee that no one would be happy with that invasion of privacy.

ShawnCplus 456 Code Monkey Team Colleague

You do realize that even if you did find out a way to do this that users could just disable javascript then take a screenshot(or do anything else that javascript is 'protecting') then re-enable javascript, right?

ShawnCplus 456 Code Monkey Team Colleague

If it's not containing the necessary variables then your "getvar" function isn't working correctly, which you don't have posted here.

ShawnCplus 456 Code Monkey Team Colleague

You're never passing an argument to the findValue function. findValue requires an argument but it is never receiving one.

ShawnCplus 456 Code Monkey Team Colleague

Give this a shot

<input type='text' name='PickupAddressPostCode' value='<?=$row['PickupAddressCode'];' />
ShawnCplus 456 Code Monkey Team Colleague

Anyway, aside from that

Notice: Undefined variable: sql in /home/book2.php on line 16

Notice: Undefined variable: a_row in /home/book2.php on line 33

Notice: Undefined variable: a_row in /home/book.php on line 34

The first error is happening because echo $sql; should be echo $query .
The second and third are happening because $a_row should be $row

ShawnCplus 456 Code Monkey Team Colleague

As per the rules, Suomedia, it's good to keep things on the site. Solving problems through PMs, email and sending attachments makes things cumbersome and difficult to search through if someone else is sharing the problem.

ShawnCplus 456 Code Monkey Team Colleague

Sorry if you got confused, this is the PHP forum, you can take a look at the JSP Forum for JSP help.

ShawnCplus 456 Code Monkey Team Colleague

While there is no browser integration that determines whether a specified window is open or not you could set a session bit once someone has visited the page then display the 'error' message if they visit it again with the bit set.

ShawnCplus 456 Code Monkey Team Colleague

onmouseover='this.height += 100;this.width += 100'
That's the most basic version.

ShawnCplus 456 Code Monkey Team Colleague

Without rival the most useful javascript debugger/general web development tool is FireBug in combination with Web Developer Toolbar.

Firebug has a very powerful debugger complete with conditional breakpoints and source tracing.

Web Developer Toolbar has a veritable cornucopia of handy tools for web developers.

ShawnCplus 456 Code Monkey Team Colleague

The easiest way to delete all rows from a table is this

var Parent = document.getElementById(tableID);
while(Parent.hasChildNodes())
{
   Parent.removeChild(Parent.firstChild);
}

Note that when using removeChild that if it removes the last element it will also delete the parent node. I guess it assumes that if you have no child nodes then you don't need the parent node.

Also, don't make a habit of making function calls inside the loop, it is costly.

var Parent = document.getElementById(tableID);
while(Parent.hasChildNodes())

Is MUCH more preferable to

while(document.getElementById(tableID).hasChildNodes())
ShawnCplus 456 Code Monkey Team Colleague

It's called the arrow operator, and when using it you don't prepend the member with $, ie.,

class SomeClass{
private $blah = "Hello";

function getBlah(){return $this->blah;}
function setBlah($value){$this->blah = $value;}
}

In another file

$something = new SomeClass();
$myBlah = $something->getBlah();
echo $myBlah; //"Hello"
$something->setBlah("World");
$myBlah = $something->getBlah();
echo $myBlah; //"World"
sagedavis commented: Thanks Shawn, your snip on PHP -> was very helpful. +1
ShawnCplus 456 Code Monkey Team Colleague

It's an integer so you must not surround it with quotes so you would do $query = "SELECT * FROM `music` WHERE `catid` = $catid";

ShawnCplus 456 Code Monkey Team Colleague
<?php
     session_start();
      if($_SESSION["status"]="logged") {
      session_unset(); 
      session_destroy();
       header( "Location:../index.php" ); 
      exit();
     } else { 
       if ($_SESSION["status"]="not logged") {
//the session variable isn't registered, the user shouldn't even be on this page 
       header( "Location:../index.php" ); 
      exit();
    }
  }
?>

Take a look at those if statements. Those are SETTING $_SESSION, not comparing them. Comparisons use ==

ShawnCplus 456 Code Monkey Team Colleague

Firstly

$query = "select * from `music` WHERE `music`.`catid` = '" . $catid . "'";

can be simplified to

$query = "SELECT * FROM `music` WHERE `catid` = '$catid'";

To order you would have

$query = "SELECT * FROM `music` WHERE `catid` = '$catid' ORDER BY `artist`";

Typically pagination is done in two ways:
1. Inside the query using LIMIT statements ie.,

SELECT * FROM `music` WHERE `catid`= '$catid' LIMIT $limitStart,20

2. Outside the query using loop limiters ie.,

for($i=$limitStart;$i<$limitEnd;$i++)

Also, is catid an integer or a varchar/text/memo field? If it is an integer surrounding it with quotes will break the query.

ShawnCplus 456 Code Monkey Team Colleague

When checkboxes are sent in requests as "on" if they are checked, if they are not checked they aren't sent at all. You're also missing an if on line 20

ShawnCplus 456 Code Monkey Team Colleague

Well firstly

$result = mysql_query("SELECT * FROM bak_bill_cust");
 while( $row = mysql_fetch_array( $result ) ):
 $option = $row["cust_code"];

echo "<option value='$row[cust_code]'>$row[cust_code]</option>";
endwhile;

>>>

$result = mysql_query("SELECT * FROM bak_bill_cust");
while( $row = mysql_fetch_assoc( $result ) )
{
    $option = $row["cust_code"];
    echo "<option value='$option'>$option</option>";
}

I actually wasn't even aware PHP could use that format for while loops but I wouldn't advise its use given that it completely breaks the Perl-like syntax and just makes for ugly code.

ShawnCplus 456 Code Monkey Team Colleague
"SELECT *
FROM `table3`
WHERE name LIKE '%hilgard\'s%'"
ShawnCplus 456 Code Monkey Team Colleague
var numInputs = 0;
function addInput(){
...
newInput.name = "upload"+parseInt(numInputs);
numInputs++;
...
}
ShawnCplus 456 Code Monkey Team Colleague

IE seems to create a tbody element after <table> so attempting to add the tr to the <table> tag will not work so we have to get the parent element then get the parent of that

function addInput(parentID)
{
       newInput = document.createElement('input');
       newInput.type = 'file';
       newInput.name = 'photo';
       var parent = document.getElementById(parentID).parent;
       var row  = document.createElement('tr');
       var td1 = document.createElement('td');
      
       parent.appendChild(row);
       row.appendChild(td1);
       td1.appendChild(newInput);
}

So no we do something like this

<table>
   <tr id='row1'>
      <td>
           <input type="button" onclick="addInput('rowID')" value="Upload Another" />
      </td>
   </tr>
</table>

This is a wee bit kludgey but it gets the job done.

peter_budo commented: Good job +7
ShawnCplus 456 Code Monkey Team Colleague

I'm not entirely sure what the extra TD is for but this is what it should look like

function addInput(parentID)
{
       newInput = document.createElement('input');
       newInput.type = 'file';
       newInput.name = 'photo';
       var parent  = document.getElementById(parentID);
       var row  = document.createElement('tr');
       var td1 = document.createElement('td');
      
       parent.appendChild(row);
       row.appendChild(td1);
       td1.appendChild(newInput);
}
ShawnCplus 456 Code Monkey Team Colleague

You might want to use a bit more descriptive names. Also, it's not working because you aren't first appending ca (the td) to anything. You must first append the new row (r) to t(parent) then append ca to r, and so on.

ShawnCplus 456 Code Monkey Team Colleague

whoops, sorry, lowercase d, document.getElementById(parentID).appendChild(newInput);

ShawnCplus 456 Code Monkey Team Colleague

Absolutely

function addInput(parentID)
{
   newInput = document.createElement('input');
   newInput.type = 'file';
   newInput.name = '<put name you want here>';
   document.getElementByID(parentID).appendChild(newInput);
}

So if you have a form such as

<form action="something.php" method="POST" enctype="multipart/form-data" id='imagesForm'>

You would have something along this lines

<input type="button" onclick="addInput('imagesForm')" value="Upload Another" />
ShawnCplus 456 Code Monkey Team Colleague
<td id="first">

V

<td class="first">
ShawnCplus 456 Code Monkey Team Colleague

You have the WHERE clauses reversed

$query = "select * from tbl_accounts WHERE $un = email AND $pw = password";

Should be

$query = "select * from tbl_accounts WHERE email = '$un' AND password = '$pw'";
ShawnCplus 456 Code Monkey Team Colleague

Well, firstly all of these things <?php echo $something ?> can be replaced by <?=$something?> . Aside from that just create an image with a grey border and nothing else(maybe a white background), call it blank and then make the image src "blank.jpg" or whatever you name it. Changing the class doesn't change the fact that there will be a broken image.

ShawnCplus 456 Code Monkey Team Colleague

Put the require after the header, also, you do not need that extremely long list of echoes, this works just as well

<?php
if(Something)
   //blah
else
{
?>
<html>
   <head><title>Test</title></head>
   <body>
       Blah
   </body>
</html>
<?
}
?>
ShawnCplus 456 Code Monkey Team Colleague

document.getElementById('states').disabled=false;

That won't work. The selectbox doesn't have an ID, set the ID to states then do the above for it to work.

ShawnCplus 456 Code Monkey Team Colleague

<listbox>.disabled = false

ShawnCplus 456 Code Monkey Team Colleague

Well in the database you would store the page name/page ID as well as the actual page in a largetext or memo field. When the page is requested by name/ID you would simply pull it from the database and display it, ie., <a href="page?id=25018">Read more...</a>

ShawnCplus 456 Code Monkey Team Colleague
mysql_connect("$host", "$username", "$password")or die("cannot connect");

There should be a space between the ) and or

Also, use [code=php] so we can use the line numbers.

ShawnCplus 456 Code Monkey Team Colleague

As a side note, you might want to obscure your server, password and username given that you just gave every single google user on earth access to it. If a mod is reading this please take that out for him.

ShawnCplus 456 Code Monkey Team Colleague

Be more descriptive with your error messages

$result=mysql_query($sql) or die(mysql_error());