Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-03-2013, 07:56 PM   PM User | #1
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
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.
Eggweezer is offline   Reply With Quote
Old 02-03-2013, 11:44 PM   PM User | #2
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
It will not work using href. Since you are using javascript already,


Look for 'location javascript' on google
__________________
Found a flower or bug and don't know what it is ?
agrozoo.net galery
if you don't spot search button at once, there is search form:
agrozoo.net galery search
BubikolRamios is offline   Reply With Quote
Users who have thanked BubikolRamios for this post:
Eggweezer (02-08-2013)
Old 02-08-2013, 02:57 AM   PM User | #3
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
Thanks for getting back. I will have to look into that. Thanks again.
Eggweezer is offline   Reply With Quote
Old 02-08-2013, 06:10 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by Eggweezer View Post
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.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
Eggweezer (02-09-2013)
Old 02-08-2013, 06:55 AM   PM User | #5
salesmachine
New to the CF scene

 
Join Date: Feb 2013
Posts: 2
Thanks: 3
Thanked 1 Time in 1 Post
salesmachine is an unknown quantity at this point
you can generate the pop up using javascript functionality..
salesmachine is offline   Reply With Quote
Users who have thanked salesmachine for this post:
Eggweezer (02-09-2013)
Old 02-09-2013, 08:52 AM   PM User | #6
JefferyJamison
New Coder

 
Join Date: Sep 2012
Location: USA
Posts: 13
Thanks: 0
Thanked 2 Times in 2 Posts
JefferyJamison is an unknown quantity at this point
HI ! Old Pedant you are write. it works.
JefferyJamison is offline   Reply With Quote
Old 02-09-2013, 05:43 PM   PM User | #7
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
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
Eggweezer is offline   Reply With Quote
Old 02-09-2013, 07:21 PM   PM User | #8
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
Quote:
Originally Posted by Old Pedant View Post
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.
__________________
Found a flower or bug and don't know what it is ?
agrozoo.net galery
if you don't spot search button at once, there is search form:
agrozoo.net galery search
BubikolRamios is offline   Reply With Quote
Users who have thanked BubikolRamios for this post:
Eggweezer (02-09-2013)
Old 02-09-2013, 08:28 PM   PM User | #9
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
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.
Eggweezer is offline   Reply With Quote
Old 02-10-2013, 01:15 AM   PM User | #10
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
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.
__________________
Found a flower or bug and don't know what it is ?
agrozoo.net galery
if you don't spot search button at once, there is search form:
agrozoo.net galery search

Last edited by BubikolRamios; 02-10-2013 at 01:34 AM..
BubikolRamios is offline   Reply With Quote
Users who have thanked BubikolRamios for this post:
Eggweezer (02-10-2013)
Old 02-10-2013, 08:32 PM   PM User | #11
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
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
Eggweezer is offline   Reply With Quote
Old 02-11-2013, 07:11 PM   PM User | #12
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by Eggweezer View Post
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.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
Eggweezer (02-11-2013)
Old 02-11-2013, 11:09 PM   PM User | #13
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
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
Eggweezer is offline   Reply With Quote
Old 02-11-2013, 11:56 PM   PM User | #14
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
just a note, are you sure you need space there (marked with underline):

$row['ID'] . '_" onclick
__________________
Found a flower or bug and don't know what it is ?
agrozoo.net galery
if you don't spot search button at once, there is search form:
agrozoo.net galery search
BubikolRamios is offline   Reply With Quote
Users who have thanked BubikolRamios for this post:
Eggweezer (02-12-2013)
Old 02-12-2013, 12:20 AM   PM User | #15
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
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.
Eggweezer is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:46 AM.


Advertisement
Log in to turn off these ads.