CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   MySQL (http://www.codingforums.com/forumdisplay.php?f=7)
-   -   Are you sure you want to delete? Not working (http://www.codingforums.com/showthread.php?t=286977)

Eggweezer 02-03-2013 07:56 PM

Are you sure you want to delete? Not working
 
I have a link that will delete an entry in my database table, but I would like a pop up that will ask if you "Are you sure". My code does not work, and I was wondering if someone could help me.
My existing code that works:
Code:

echo '<td><a href="delete_job.php?id=' . $row['ID'] . ' ">Delete</a></td>';
Now my new attempt that does not work:
Code:

echo '<td><a href="delete_job.php?id=' . $row['ID'] . ' " onclick="return confirm('Are you sure you want to delete?')">Delete</a></td>';
Thank you very much in advance.

BubikolRamios 02-03-2013 11:44 PM

It will not work using href. Since you are using javascript already,


Look for 'location javascript' on google

Eggweezer 02-08-2013 02:57 AM

Thanks for getting back. I will have to look into that. Thanks again.

Old Pedant 02-08-2013 06:10 AM

Quote:

Originally Posted by Eggweezer (Post 1310713)
Now my new attempt that does not work:
Code:

echo '<td><a href="delete_job.php?id=' . $row['ID'] . ' " onclick="return confirm('Are you sure you want to delete?')">Delete</a></td>';

I think Bubikol is totally wrong. That should work just fine.

Bring up the page in your browser.
Click on the browser's VIEW menu.
Click on the SOURCE or PAGE SOURCE menu item.
Find that line in the HTML and copy/paste the HTML here.

salesmachine 02-08-2013 06:55 AM

you can generate the pop up using javascript functionality..

JefferyJamison 02-09-2013 08:52 AM

HI ! Old Pedant you are write. it works.

Eggweezer 02-09-2013 05:43 PM

Hello all.
I hate to sound ignorant, but I get an error with that line of code.
This is the error that I get:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /homepages/41/d383225633/htdocs/test38/admin/view_jobs.php on line 58

BubikolRamios 02-09-2013 07:21 PM

Quote:

Originally Posted by Old Pedant (Post 1311867)
I think Bubikol is totally wrong.

Hmm, realy, I tested it on FF and GC and there it works, on IE8 does not work as expected, whatewer you click it goes to href.

Anyway I don't know how java script can affect/connect to href value.
Does not look logical to me.

Eggweezer 02-09-2013 08:28 PM

Thanks BubikolRamios.
Yeah, I don't even get it to work in Chrome.
When I upload the file and view the page, it just displays that syntax error.

BubikolRamios 02-10-2013 01:15 AM

Try this, id does not actualy delete anything, it demonstrates linking upon confirmation.

The bottom link should work on all browsers, while upper does not work on IE 8.


Code:

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <a href="https://www.google.si/" onclick="return confirm('Are you sure you want to delete?')">Delete href</a>
        <br />
        <a href ="#" onclick="if (confirm('Are you sure you want to delete?')) {window.location.href = 'https://www.google.si/';}">Delete javascript</a>
       
    </body>
</html>

Otherwise your error looks like from PHP.
It has nothing to do with .....

When your PHP will be error free, then you wil still have to look at html page source (and that should look something like my upper code.)

I doubt you can look at PHP generated html source as old pedant suggested, at this stage, coz I asume it is nothin there, due to error.

EDIT: Not PHP man myself, but if you look here: http://php.net/manual/en/language.operators.string.php

all strings are inside "" not inside '' like in your case ..... There might be your problem.

Eggweezer 02-10-2013 08:32 PM

Thanks BubikolRamios.

Your code did work when it was the only thing on my page, BUT.... did not work when I tried to incorporate it within my code(hyperlink).I just got a syntax error.

If you (or anyone) wouldn't mind, you can the actual domain at http://clearcreekhoney.com
That way you could actually edit it. I know it is a hassle for you, but I am getting frustrated, and am trying to cross (understand) this hurdle.

The ftp info is:
Username: u65618807-CLRcreek
Password: !clear23

My delete does work, BUT not with the "warning" popup.
Thank you. Sincerely, Eggweezer

Old Pedant 02-11-2013 07:11 PM

Quote:

Originally Posted by Eggweezer (Post 1312235)
Hello all.
I hate to sound ignorant, but I get an error with that line of code.
This is the error that I get:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /homepages/41/d383225633/htdocs/test38/admin/view_jobs.php on line 58

That is a PHP error. It has nothing whatsoever to do with whatever browser you are using.

PHP code happens *BEFORE* the browser ever *SEES* the code, at all.

If you don't show the PHP code where that error is nobody can help you.

HINT: Any error message that includes T_xxxx is a PHP error. Unless you actually had a variable or function name that started with T_ there is no standard JavaScript error that would look like that.

Eggweezer 02-11-2013 11:09 PM

Here is my code that DOES NOT give an error, and correctly goes to the hyperlink.
Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>
<body> 
<?php
require ('mylogin.php');
        $db = connectDB();

    $result = mysql_query("SELECT * FROM customers order by crm ASC") 
                or die(mysql_error()); 
           
?>
    <table border='1' cellpadding='10'>
    <tr><th>Last Name</th><th>First Name</th></tr>

<?php
    $count= 0;
        while($row = mysql_fetch_array( $result )) {
    ++$count;
               
          echo "<tr>";
          echo '<td width="100">' . $row['nameLast'] . '</td>';
          echo '<td width="100">' . $row['nameFirst'] . '</td>';
          echo '<td><a href="delete.php?id=' . $row['ID'] . ' ">Delete</a></td>';
      echo "</tr>"; 
    } 
      echo "</table>";       
?> 
</body>
</html>

Here is my code with only the "Delete" line modified (which DOES give the PHP error).
Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>
<body> 
<?php
require ('mylogin.php');
        $db = connectDB();

    $result = mysql_query("SELECT * FROM customers order by crm ASC") 
                or die(mysql_error()); 
           
?>
    <table border='1' cellpadding='10'>
    <tr><th>Last Name</th><th>First Name</th></tr>

<?php
    $count= 0;
        while($row = mysql_fetch_array( $result )) {
    ++$count;
               
          echo "<tr>";
          echo '<td width="100">' . $row['nameLast'] . '</td>';
          echo '<td width="100">' . $row['nameFirst'] . '</td>';
         
          echo '<td><a href="delete_job.php?id=' . $row['ID'] . ' " onclick="return confirm('Are you sure you want to delete?')">Delete</a></td>';
         
      echo "</tr>"; 
    } 
      echo "</table>";       
?> 
</body>
</html>

If anyone can figure this out, I would greatly appreciate it. Sincerely

BubikolRamios 02-11-2013 11:56 PM

just a note, are you sure you need space there (marked with underline):

$row['ID'] . '_" onclick

Eggweezer 02-12-2013 12:20 AM

I just removed the space to no avail.

If it helps, you can see it at www.clearcreekhoney.com

If it is easier for you, you can download the index.php file and play with it (of course, unless it is a hassle)

The ftp login is:
Username:
u65618807-CLRcreek
Password: !clear23

Thank you.


All times are GMT +1. The time now is 01:10 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.