Posts

Showing posts from April, 2014

how to work ajax and php in single code

this link show what do you wanted    its' simpler and great demo http://simpletutorials.com/?path=tutorials/javascript/simple_ajax

PHP: give alert popup then redirect the page

Do something like header ( "Location: index.php?Message=" . urlencode ( $Message )); Then on index.php... if ( isset ( $_GET [ 'Message' ])) { print $_GET [ 'Message' ]; } In other words, index.php will always check if it's being passed a message in the url. If there is one, display it. Then, just pass the message in the redirect if you really want to use a modal popup, generate the js... if ( isset ( $_GET [ 'Message' ])) { print '<script type="text/javascript">alert("' . $_GET [ 'Message' ] . '");</script>' ; }

PHP: give alert popup then redirect the page

code goes this   if ( $_FILES [ 'file' ][ 'size' ] > 200000 ) //any file size, 200 kb in this case { echo "<script type='javascript'>alert('File size larger than 200 KB')</script>" ; } header ( "Location: index.php" );         The browser will be redirected to index.php page anyway, no matter the file is successfully uploaded or not. Its just that the popup will appear if the file is of larger size.

Javascript Confirm Delete in One PHP File (on href)

You can set the onclick attribute of the link. If the function returns false , the link will not proceed. <a href = "deletephone.php?id=' . $row['id'] . '" onclick = " return confirm ( 'Are you sure?' ); " > Delete Phone </a> Here, the confirm() function will return true if the user pressed OK, and false if the user pressed Cancel.

echo javascript with single quotes

You are echoing outside the body tag of your HTML. Put your echos there, and you should be fine. Also, remove the onclick="alert()" from your submit. This is the cause for your first undefined message. <? php $posted = false ; if ( $_POST ) { $posted = true ; // Database stuff here... // $result = mysql_query( ... ) $result = $_POST [ 'name' ] == "danny" ; // Dummy result } ?> <html> <head></head> <body> <? php if ( $posted ) { if ( $result ) echo "<script type='text/javascript'>alert('submitted successfully!')</script>" ; else echo "<script type='text/javascript'>alert('failed!')</script>" ; } ?> <form action = "" method = "post" > Name: <input type = "text" id = "name" name = &qu

why we use this function mysql_real_escape_string()

when we are entering data in to mysql database and that contain the single quote. that time data is not entering into database and showing error then we we use this function . there are other function to remove the the to remove the quote but this one is easier one thank you

MySQL error: “Column count doesn't match value count at row 1” - beginner help

I understand that you're not providing a value since it's likely a PRIMARY KEY that autoincrements. To tell MySQL that you are intentionally not passing a value for that column, you should add NULL as the first value.

need to remove an apostrophe ‘ from a string

$newaddress = str_replace("'", "", "$address"); That should work, for other answers visit [ php.net ...]

MySQL error when inserting data containing apostrophes

this should work....... $result=mysql_query("INSERT INTO $table wf_FirstName1,wf_LastName3) VALUES ('".mysql_real_escape_string($wf_FirstName1)."', '".mysql_real_escape_string($wf_LastName3)."')"; :)

MySQL error when inserting data containing apostrophes (single quotes)

Apostrophe Delimiter In the MySQL version of SQL, you signal the beginning and the end of a string with either single quotes or double quotes. Both of the following examples are valid: INSERT INTO COMPANY_TABLE (company_name) VALUES ‘The Fish Shack’; INSERT INTO COMPANY_TABLE (company_name) VALUES “The Fish Shack”; The following example, however, creates an error: INSERT INTO COMPANY_TABLE (tag_line) VALUES ‘Eat at Joe’s -- It’s Good Food!’; SQL wants to interpret the string as "‘Eat at Joe’," with everything following the second apostrophe as erroneous. The following text does not fix the problem: INSERT INTO COMPANY_TABLE (tag_line) VALUES “Eat at Joe’s -- It’s Good Food!”; This would work if the text had only one apostrophe between the double quotes, but this text has two. Also, because some Web-page programming languages use double quotes themselves, you may wish to avoid using them in your SQL.

What is PHP.

PHP is server side scripting language. that's the way all are define. why server side scripting.        the code we are written in php is executing on server side and what ever the output come out is shown as html form.