Graphix 68 ---

Hi!

A few things you might consider:
>> First debug your code and find the source of your problem, then post the small piece of code that is flawed so that we do not have to spit through all your code (which I, for one, am not going to)
>> If you are a novice in JavaScript, you might consider starting with easier things instead of adapting difficult code.
>> If you did not write the script, we can not help you fix it. Seek help at the author of the script.

~G

Graphix 68 ---

1. You put each mile in an array and each name
2. You sort the miles-array: http://php.net/manual/en/function.sort.php or an equivalent function (you can always write your own -> good for learning)
3. You run through the array echo'ing each element.

~G

Graphix 68 ---
diafol commented: Thank you G - saves me posting a sarcy comment +14
Graphix 68 ---

Umm, try this checklist:

A. Is "users" the correct table?
B. Is the name of the column that holds the level really "level", as you described on line 25?
C. You should have fixed it by now, if not, post a reply :)

~G

Graphix 68 ---

Hi tstory28,

After a quick look through your code, I would like to suggest a few things:

- Put a new if statement around line 6 to 61, in which you check whether the email and password form variable are set (if (isset($_POST['email) && .....) and delete the if statement in line 10

- Line 7, 8 - Clean the form value first: $variable = htmlentities(addslashes($_POST['form_variable'])); - Line 26 - Add an echo in which you show all the variables from the database:

echo "dbemail=".$dbemail.", dbpassword=".$dbpassword.", dbname=".$dbname.", dblevel=".$dblevel;

If you did all those steps (especially the last one), you will find out why your code is not working (probably because dblevel is empty, but you'll see)

~G

tstory28 commented: This helped me find my issue. +1
Graphix 68 ---

You need to encase your code in code tags, one that opens, one that closes (without the spaces between the []):

[CODE ] Some code.... [/CODE ]

Anyway, on to your code:

  • You misspelled getElementById by changing the 't' into a 'd'
  • You kind of messed up the brackets in the CheckAnswer() function

The code was written OK, so my complements for that ;) I adjusted the code a bit so that it is more commented and spaced:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Math Quiz</title>
</head>
<body>

<script type='text/javascript'>
var PlayerWins = 0;
var PlayerLosses = 0;

function CreateRandomNumber() {

  /* Calculating and returning random number between 0 and 100 */
  return Math.floor(Math.random() * (100 + 1));

}

function CreateRandomOperator(){

  /* Calculate random number between 0 and 1 */

  var Operator = "";

  var val = Math.floor(Math.random() * (1 + 1));

  if(val == 0) {
    Operator = "+";
  } else if (val == 1) {
    Operator = "-";
  }

  return Operator;

}

function CheckAnswer() {

  /* Retrieving the two numbers and the player's answer: */
  var Number1 = parseInt(document.getElementById('Number1').innerHTML);
  var Number2 = parseInt(document.getElementById('Number2').innerHTML);
  var Operator = document.getElementById('Operator').innerHTML;
  var Player_Answer = parseInt(document.getElementById('Player_Answer').value);

  /* First you check whether the answer is correct: */

  if (Operator == '+') {

    if(Player_Answer == Number1 + Number2){

        PlayerWins++

        /* Showing status: */
        alert('Correct answer!\nWins:' + PlayerWins + '\nLosses:' + PlayerLosses);

    } else if (Player_Answer != Number1 + …
Graphix 68 ---

Alright, I guess you stopped reading my posts which provided the solution and which only need one more adjustment to work with the table you described in your last post. Finding a solution when you show no effort on solving your OWN problem and use youtube films to learn PHP, is not going to work...

Good luck.

Ezzaral commented: Agree +14
Graphix 68 ---

It's not the fault of the HTML nor CSS, if you would read the sourcecode, you would see that after every dot (.) there is a unknown character icon. This is caused by your editor that you use to type the text (your CMS perhaps), which adds a unknown character after every dot.

~G

PS: You should validate your CSS using w3 CSS validator, on first glance, I saw that line 5 should be: font-style:none;

Graphix 68 ---

I hope you set the variable $id in code you have not shown yet, and cleaned that with htmlentities() and addslashes(). If you are counting on register_global of PHP, you are creating a huge security leak. Well anyway, to solve your problem, you first need to select the row, check whether there is a row with that id (num_rows > 0) and then delete it:

$q1 = "SELECT * FROM databasemanager WHERE id='".$id."' LIMIT 1";
$r1 = mysql_query($q1) or die("Could not retrieve row. 1");

if (mysql_num_rows($r1) > 0) { // If the id exists

$q2 = "DELETE FROM databasemanager WHERE id='".$id."' LIMIT 1 ";
$r2 = mysql_query($q2) or die("Could not delete row. 2");

// The rest of your code...

}

~G

Graphix 68 ---

Although I do not have any experience with Rotating ad banners, I do see the cause of your problem:

>> Line 6, 7, 8 - It is a mix of various quotes and they are aligned wrong. Use the following:

textads[0] = "<a href=\"http://www.leighfibers.com\" target=\"_blank\" onClick=\"javascript: _gaq.push(['_trackPageview', '/bannerad/leighfibers']);\" ><img src=\"http://www.sleepproducts.org/ISPANEW/images/bannerads/August_LeighFibers.jpg\" border=\"0\"></a>"; 
textads[1] = "<a href=\"http://www.henkelna.com/foambonding2\" target=\"_blank\" onClick=\"javascript: _gaq.push(['_trackPageview', '/bannerad/henkel']);\" ><img src=\"http://www.sleepproducts.org/ISPANEW/images/bannerads/July_Henkel.jpg\" border=\"0\"></a>"; 		  
textads[2] = "<a href=\"http://www.storksmt.com/Stork/6212/Bedding_Evaluation.html\" target=\"_blank\" onClick=\"javascript: _gaq.push(['_trackPageview', '/bannerad/stork']);\" ><img src=\"http://www.sleepproducts.org/ISPANEW/images/bannerads/August_Stork.gif\" border=\"0\"></a>";

~G

Graphix 68 ---

Thats fairly easy:

<script type='text/javascript'>window.onload=function(){ update(document.getElementById('qty')); }</script>

You should place this beneath the form HTML, so that the id already exists.

~G

pietpiraat commented: Great helper +0
Graphix 68 ---

As far as I could see, there does not exist a counter folder in which a count.db exists. So create a folder named "counter" and create a file in that named "count.db"

~G

Graphix 68 ---

Howmanny times do I need to post this on DaniWeb:

AJAX is a set of functions of the language JavaScript

jQuery is a set of functions written in JavaScript, it might be considerate as a library for JavaScript but is not build-in and needs to be included using the script tag. More information: http://jquery.com/

JavaScript is a browser language.

~G

Graphix 68 ---

You forgot to post your code? We can't help you if you do not post it.

~G

Graphix 68 ---

Please bore us with unsuccesfull code, so we can make it succesfull. That is the entire point of this forum.

We are glad to help people with their own code, but we don't like writing code for people that don't show effort or order us to make the code.

~G

Salem commented: Nicely put :) +19
Graphix 68 ---

Hey everybody,

Lately I have written the game Hangman in many different languages (C, JavaScript, Java and PHP so far). Here is the code snippet for Java! It uses a words file, on the bottom of this post you will see a small example of a few words. The source code for other languages can be found here on DaniWeb and on my new website: http://www.hangman.symbolwebdesign.nl/.

Due to the fact it is not possible (in web apllications) to open a words file using Java, it is required to directly put the words string separated by a | into the string variable. Modify the string in the initGame() function in the script (line 59).

~G

Graphix 68 ---

Google a bit before you start asking questions?

The number 1 result is a website that holds all the information for captcha: http://www.captcha.net/

However, for some reason, you want to program your own:

http://www.codewalkers.com/c/a/Miscellaneous/Creating-a-CAPTCHA-with-PHP/

~G

Salem commented: Well said! +19
Graphix 68 ---

There has been atleast 5 image upload questions on this forum. There are tons of image upload scripts on the internet. If you can't retrieve and insert rows from a database using PHP, you should probably read a beginners book like PHP & MySQL for Dummies.

A few helpful links for image-uploading:

> http://www.daniweb.com/forums/thread214601.html
> http://www.webdeveloper.com/forum/showthread.php?t=101466

Don't say you searched the web when you have not even looked at the first page of Google search results for "php image upload"

~G

Graphix 68 ---

You can just simply echo the links? I don't understand what can possibly go wrong?

$blogs = get_last_updated();
echo 'Most active mommies:';
echo '<ul>';
foreach ($blogs AS $blog) {
    echo "<li><a href=\"".$blog['domain']."\">".$blog['domain']."</a></li>";
}
echo '</ul>';
Graphix 68 ---

>> You want the form to be checked before submitted:

Change the form tag into:

<form id="form1" name="form1" method="post" action="sendform.php" onsubmit='return isValid()'>

And the submit button into:

<input type="submit" name="button" id="button" value="Submit order" />

And the checkbox into:

<input type="checkbox" name="checkbox" id="checkbox"  value="agreed"/>

Then use the following javascript function:

function isValid() {
var checkbox = document.getElementById('checkbox').checked;
var mot = document.getElementById('Is Vehicle Roadworthy with Full M.O.T.').value;
if (mot == "Yes" && checkbox == true) {
	return true;
} else {
     if (mot != "Yes") {
	  alert("Your vehicle must be roadworthy with full M.O.T.");
	 }
	 if (checkbox != true) {
	  alert("You have to agree with the Terms and Conditions");
	 }
     return false;
}
}

>> You want to redirect the user after submitting

Place the following code at the end of sendform.php:

header('Location: http://www.n-v-m.co.uk/Thankyou.html');

~G

Graphix 68 ---

I see you found a solution for it yourself. However the way you solved is a bit on a cumbersome manner. If you want a form to not be submitted, you just adjust the form tag:

<form action="" method="post" onsubmit="return false;">
...
... The form
...
</form>

This way, also when the user presses the enter-button on his keyboard, the form won't be submitted.

~G

Graphix 68 ---

I would first advice that you write the HTML code (or generate it in php). Then, when the page is shown properly, you start writing the AJAX-based functions one by one. This is to prevent that your code doesn't work and that you have no idea where it all went wrong.

I learned AJAX and alot of PHP from the book PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)

A few links to online AJAX tutorials:

w3schools
Tizag

You can also Google yourself.

~G

Graphix 68 ---

It really requires little work:

<script type="text/javascript">
function show(Id) {
document.getElementById(Id).style.display="inline";
}
</script>
<span onmouseover="show('myImage')">Hover here to see the image!!!</span>
<img src="someImage.jpg" id="myImage" border="0" style="display:none;" />

~G

Graphix 68 ---

>> Line 13 - You forgot to add the {} at the else. You should always use an if...else the following:

if (...condition...) {

} else {

}

>> Line 14 - Never use a document.write() in a function you call when the page is already loaded. Use a custom message box or use alert("Message"); >> Line 22 - You should use the event onkeypress="check()" instead of onchange="check()" ~G

Graphix 68 ---

JQuery is one way to go,
You should take a look here:

http://www.learningjquery.com/2006/09/slicker-show-and-hide

First google before you post, there are alot of tutorials and explainations on the internet.

~G

Graphix 68 ---

This script can be used for star ratings on for example forum or music sites. The scriptinformation is included within the script.

~G

Graphix 68 ---
$error = array();
$results = array();

if (isset($_GET['search']) && isset($_GET['field'])) {
   $searchTerms = trim($_GET['search']);
   $searchTerms = strip_tags($searchTerms); // remove any html/javascript.
  $searchField = trim($_GET['field']);
  $searchField = strip_tags($searchField);
  $searchField = addslashes($searchField);
   
   if (strlen($searchTerms) < 3) {
      $error[] = "Search terms must be longer than 3 characters.";
   }else {
      $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection.
   }
   
 
   if (count($error) < 1) {
      $searchSQL = "SELECT sid, sbody, stitle, sdescription FROM simple_search WHERE $searchField LIKE '%$searchTerms%' ";         
         
      @$searchResult = mysql_query($searchSQL);
     
      if (mysql_num_rows($searchResult) < 1 || !$searchResult) {
         $error[] = "The search term provided {$searchTerms} yielded no results.";
      }else {
         $results = array(); 
         $i = 1;
         while ($row = mysql_fetch_assoc($searchResult)) {
            $results[] = "{$i}: {$row['stitle']}<br />{$row['sdescription']}<br />{$row['sbody']}<br /><br />";
            $i++;
          } // End of while
       } // End of else
    } // End of error check
} // End of isset()
Graphix 68 ---

A few suggestions:

- How to debug your code
- How do you use an include() and how do you acces files beneath the webroot?
- How do you secure your site, what techniques can be used and what shouldn't you do.
- When should you use sprintf(), printf(), print(), echo() and how do you use them (%f,%d etc. and wether you should use single quotes(') or double quotes("))

~G