This hurts me more than it hurts you, but...
Let me google that for you!

phorce commented: Brilliant! +6

Welcome to Daniweb albertsibanda9 :)
The long answer:
Read This Before Posting A second Question
The short answer:
Post your code before LastMitch gets hold of you :D

<M/> commented: well said... +5
LastMitch commented: LOL - that's a good one Adam! =) +6
diafol commented: Hilarious +14

$alert_error = "<script type=\"text/javascript\"> alert('".mysql_error()."') </script>";
In the above line you are referencing 'mysql_error()', but it doesn't exist yet because you did not run the query that produces the error.
Also, you wanted Javascript to alert the value of 'mysql_error()':

if (!$query = mysql_query("DELETE FROM abc WHERE id ='$id'")){
    echo "<script type=\"text/javascript\"> alert('".mysql_error()."') </script>";

The above works when I test it.

I only noticed afterwards that the title said 'using PHP':

//check to see if the form was submitted
    $theme = $_POST['theme'];//set to selected theme
} else { 
    $theme = "default.css";//set to default
<!-- use PHP to echo the location of the stylesheet -->
<link id="stylesheet" rel="stylesheet" type="text/css" href="<?php echo $theme; ?>" />

<!-- The action of the form will default to self -->
<form method="post">
<select name ="theme">
<option value="default.css">Default</option>
<!-- The PHP code in next part would be better in a separate function -->
<!-- It sets the dropdown to selected on the currently selected theme -->
<option value="dark.css"<?php if ($theme == "dark.css") echo " selected"; ?>>Dark</option>
<input type="submit" name="submit" />

Learn, don't just copy :)

Using javascript:

<!-- You must have the id set in the next line -->
<link id="stylesheet" rel="stylesheet" type="text/css" href="default.css" />
<script type="text/javascript">
function switchStyle(el){
    //get selected theme
    var styleSheet = el.options[el.selectedIndex].value;
    //apply the new style using id set earlier.
    document.getElementById('stylesheet').href = styleSheet;

<!-- (this) refers to the select element -->
<select id="theme" onchange="switchStyle(this)">
<!-- value corresponds to stylesheet filename --> 
<option value="default.css">Default</option>
<option value="dark.css">Dark</option>

I believe we have two insert types with MySQL:
"INSERT INTO tablename set field='value', column='amount'...", and
"INSERT INTO tablename (field, column) VALUES ('value', 'amount')"
But your query is a mixture of both and neither:
"INSERT INTO ".$table." values $fld='$this->add_security($val)'"

$check= mysql_query("SELECT FROM accounts WHERE (email='".$email."')");
Select what from accounts? ALL, Id etc? I guess error checking the query would have given an error.

vaultweller123 is exactly right.

If you declare a variable:
$variable = "value";
...and then you declare the same variable with a different value:
$variable = "another value";
...the variable holds the second value and the first value is lost.
It is the same in your loop, your variable '$url' can only hold one value at a time, so you need to process the value each time through the control loop, for example:

for($x = 0;$x <count($_FILES['image']['name']);$x++){
    //here the value of $url is echoed along with the other HTML.
    echo "<center><td><input type='text' size='50' value=\"";
    echo $url;
    echo "\"/></td><center>";

or you can store the value in an array and work with it afterwards:

$urls = new array();
for($x = 0;$x <count($_FILES['image']['name']);$x++){
    $urls[] = $url; //here the value of $url is saved in the $urls array. 

then user a foreach, for instance:

foreach($urls as $url){ //no need to count, when there are no more urls, the loop stops.
    echo "<center><td><input type='text' size='50' value=\"";
    echo $url;
    echo "\"/></td><center>";

Good luck :D

$loc_considered1 = implode(', ',$loc_considered); is the problem line.
implode() expects parameter one to be a string (which it is) and parameter two to be an array, which it probably isn't. Where is the form that produces the $_POST['loc_considered'] variable?
Can you post that code?

Was your code hit by a truck?

#nav ul {
width: 100%;
float: left;
margin: 0 0 0 0;
padding: 0;
list-style: none;
background-color: #fff;
position: absolute;
top: 162px;
left: 550px;

You have 100% width AND absolute positioning, I guess the unecessary whitespace is 550 pixels.

Both of your functions have the same name, so presumably the second version is overwriting the first one, meaning that really there is only one function - the second one. Did you try to name the two functions differently and add both functions to the onclick event of the button?

function OnButtonA(){
//send form to location one.
function OnButtonB(){
//send form to location two.
onclick="OnButtonA(); OnButtonB();"

If this doesn't work, I would try to use Ajax to achevieve the desired result.

I'm not familiar with this syntax:
I would do it a bit differently:

<!--use a table class rather than repeat font face declaration every line-->
<table class="table" border="1" cellspacing="2" cellpadding="2">

// You don't need to run a while loop depending on num_results,
// just use while(mysql_fetch_array), will stop when no more results.

$sql = "SELECT * FROM tablename";
if(!$result = mysql_query($sql)){// put all DB operations inside error check loop
    die('Invalid query: ' . mysql_error());
if(!mysql_num_rows($result) > 0){// using num_rows to make sure there are results to display.
    die("no results, aborting...");

while($row = mysql_fetch_assoc($result)){
    echo "<tr><td>".$row['name']."</td>"; //<tr> on the first row
    echo "<td>".$row['correct']."</td>";
    echo "<td>".$row['wrong']."</td>";
    echo "<td>".$row['percentage']."</td>";
    echo "<td>".$row['level']."</td>";
    echo "<td>".$row['date']."</td></tr>"; //close </tr> on last row.

@MWEB, you are drowning in confusion, lets go over it step by step.

Make a form, set the action to the page you want to process the details and the method(get).

Collect form variable/s ready for database search:
$res = $_GET['res'];

Make connection using error checking:

if(!$con = mysqli_connect($host, $user, $pass)){
    echo mysqli_error(); die();

Select database using error checking:

if(!mysqli_select_db("db")) {
    echo mysqli_error(); die();

Build database query:
$sql = "SELECT id, price FROM edit WHERE id='$res' ORDER BY id ")

Send query using error checking:

if(!$res = mysqli_query($sql)){ //error, kill script and tell me what is wrong.
    echo mysqli_error(); die();
} else { //no error continue...
    if(mysqli_num_rows($res)){//no error, but are there any matches?
        while($row = mysqli_fetch_assoc($res)){//there are matches, do the thing...  
            $id = $row['id'];//this step not essential, 
            $price = $row['price'];// but keeps code clean and easy to read.
            echo "$id: The price is $price,<br />"// <--see? clean, easy to read :D
    } else {//no matches, say so
        echo "There were no matches to the search.";

Pritaeas has written an excellent guide:
If there are no DB errors and still no results, try running your query in PHPMyAdmin. You can echo your query to the screen:

$sql = "SELECT id, price FROM edit WHERE id='$res' ORDER BY id ");
echo $sql; die();

...and paste it directly into PHPMyAdmin to see if there is any difference.
Good luck! :D

$query = mysqli_query($con, "SELECT id,price FROM edit WHERE id=$res");

...this was correct, but lacked the 'ORDER BY' clause, so :

$query = mysqli_query($con, "SELECT id, price FROM edit WHERE id=$res ORDER BY id"); all that needed changing, but when urtrivedi changed it to:

WHERE id='{$_GET['res]}' went horribly wrong because it should be '{$_GET['res']}' (utrivedi missed a single quote after the s). I prefer to keep the MySQL statement clean and easy to read as Andreret demonstrated.
This is the bread and butter of PHP/MySQL web development, you should read a thousand tutorials until you can do this in your sleep.

AndreRet commented: Thanx +12

a tablename that consists only of digits may need to be encapsulated with `backtick`s - look here

I see no reference to "%i" in the manual.

Line 8: (mysql_fetch_row($result)>0) is this intended? do you mean (mysql_num_rows($result)>0) ?
All your database interactions should be ready for errors:
if (!$var = mysql_query()) die(mysql_error())
Line 16: the string $sql is wrong, look here to see why:
Lines 24+27: You don't use a comma to concatenate a string.
Line 24: $_POST["prenom "] <- the key has whitespace.

As for the double entry into the database and the text file, is this ALL the code? I can't see where it is happeneing twice, or even how this script is running with the comma's for concatenation.

I tested your code on my local windows machine:

$file = "testFile.txt";
$fh = fopen($file, 'a+') or die("can't open file");
$firstname = "firstName"; $lastname = "lastName"; $mood = "mood";
$datestring = date("d/m/y ");
$timestring = date("H.i.s");
$data   = "$firstname ; $lastname ; $mood ; $datestring : $timestring\r\n" ;
$data  .= "$firstname ; $lastname ; $mood ; $datestring : $timestring\r\n" ;
fwrite($fh, $data);

and it printed:

firstName ; lastName ; mood ; 19/10/12  : 12.00.35
firstName ; lastName ; mood ; 19/10/12  : 12.00.35

to the testFile.txt
I also tested it on my remote unix based host and it gave exactly the same result. Maybe I can see all the code concerned?

Hey, I liked the challenge, so I tried it out.

//in the head section: This function makes the text input elements depending on the number selected in the options.

<script type="text/javascript">
function makeInputs(amt){
    var str="";
        str += 
        "<input type=\"text\" name=\"text_" + 
        (i+1) + "\"" + 
        " id=\"text_" + i + "\"" +
        " value=\"\" />\n";
    document.getElementById('inputs').innerHTML = str;

//in the body, this makes the select area on the page, also there is a div in which to show the text inputs when they are made.

<select style="width:160px;" id="text" name="participants" required="required">
<option id="" value="" name="">-Select participant-</option> 
<script type="text/javascript">
    "<option id=\"opt_" + i + 
    "\" value=\"" + i + 
    "\" name=\"opt_" + (i+1) + 
    "\" onclick=\"makeInputs(" + (i+1) + ")\">" + (i+1) + 
<div id="inputs">

Hope this helps, any more questions let us know.

So the new row is inserted before the page is built, and PHP writes the result (success/failure) to a hidden form element. Use to activate a javascript fucntion that shows the image for desired amount of time.
Or use ajax to insert data via a separate php file and show the message on return of the ajax response.

Ok, but both IF statements have the same OR clause (!== ''). Which, if evaluates to TRUE will mean your other condition (!isset) isn't tested.

Hey again :)
First, good job with the pages showing your testing!
You send the variable via the URL so it must be retrieved via the $_GET array on the test.php page. This works fine with the link you have at the bottom of the page because the &name=value pair is certainly passed in the link. However, when the form is submitted using the submit button the $_GET variable is not available. This is because the &name=value pair is not in the url.
So how does the form page know know where to redirect to when it is submitted? Because the URL is in the action declaration of the form - action="/test.php". So if you want to take a variable from the url, you could add it to the action - action="/test.php?foo=bar", which will acheive the desired effect.
The problem is that you are declaring the variable on the outer page (presumably index.php), and then trying to collect that variable in delete.php, this will never work because the variable was never available to the page delete.php with the submit button.
Hope this helps, let us know how you get on.

php might be involved but to display something on page for a few seconds is a task for javascript so maybe you need to start this thread in that forum to get the best chance of a relevant and timely answer i also recommend using punctuation in your post as if you are too lazy or impatient to explain your problem clearly you are also probably too lazy and impatient to write your code properly and it will be a painful thing to help you

Hey that's great! Be aware that $_GET is a global by default, so you could reference it in your function, also you could have passed the variable to the function (prefered method) -

function delete($file){//everytime you want function to access variable... 
    if (unlink($file)){//it must referenced by the variable in the function declaration - ($file).
    //do functionary things

and call the function with the variable passed:

$filename = $_GET['filename'];//define $filename
delete($filename);//send $filename to function.

You could also have passed $_GET['filename'] to the function -


Well done :D

bradly.spicer commented: Helpful :) +0

You have discovered variable scope:
See if you can work it out, let me know if you get stuck :)
Good luck!

Index.php - fix your HTML tags, you close the page before you open it. You haven't named your select element and won't be able to access the selected file. Your form has no method.
Delete.php looks ok, but fix index before you worry about it.
You should write print_r($_POST); die(); at the top of delete.php and don't remove it until you see the filename as you want it to be sent to the function.

You need to learn how to build a form in HTML, then how to grab the data entered using PHP. This is the bread and milk of PHP, there are multitudes of tutorials online.
Good luck! :D

Have a look at the error mysql reports:

if (!$res = mysql_query($query)){
    echo mysql_error(); die();

It should give you the specific problem.

The problem is with the $_GET['error'] variable - in one place it is $_GET in the next palce it is $GET without the underscore. You need the underscore in both instances, $GET is not the same as $_GET. Also you can send the message via the URL (the get method), but as Daniel shows the message can be given on the login page as presumably there is only one error message and therefore no need to carry it from one page to another?

Haha, no problem, I did it many times.