PHP session lost after redirecting the page

I was inserting some data and was trying to show my success message using SESSION variables in PHP. my code segment of samplepage.php was like this: and below this segment I was catching the $_SESSION[‘MySuccessMsg’] in a div in top of my HTML body: so every time the page was redirected after $success==1 condition segment, I found no data in $msg. Later I found a … Continue reading PHP session lost after redirecting the page

How to avoid duplicate entry in each page reload after PHP submit

I was using form submit using method=’POST’ and action=$_SERVER[‘PHP_SELF’]. I added data in my DB successfully but whenever I manually reloaded my page, it was a duplicate entry. using POST variables carefully, I was unable to resolve the problem. here goes my code segment of samplepage.php: Later, I realized that no matter what how I check the post variables and use them carefully, the variables … Continue reading How to avoid duplicate entry in each page reload after PHP submit

Difference between include() and include_once() Functions in PHP

When should I use require vs. include? The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop. When should I use require_once vs. require The require_once() statement is identical to require() except PHP will check … Continue reading Difference between include() and include_once() Functions in PHP

localhost error :: connection Failed The system returned: (111) Connection refused

I installed my apache server in my PC, but yet, I couldnt load "localhost" . the error was. I was using Mozilla Firefox and IE both. While trying to retrieve the URL: http://localhost/ The following error was encountered: Connection Failed The system returned: (111) Connection refused Finally the solution I found was interesting! Go to the LAN settings (in Chrome : Tools-> Options-> Under the … Continue reading localhost error :: connection Failed The system returned: (111) Connection refused

Opening a pop up window using Javascript

I was in need of a JS function of opening a pop up window. I found a wonderful tutorial about this from Here Here is the Javascript Function for POP UP window named popitup() The interesting part is, the the window.open() function. The arguments of this function are mainly three. First one is URL, second is NAME. and in third one we can put many … Continue reading Opening a pop up window using Javascript

sending php array variable as link to argument of javascript function

I have got a javascript function popitup() which will be used for opening a pop up window. I have PHP Array variable $row_rstest[‘id’] which holds the ID of a data set fetched from database. I have a page named print_data.php. To view the data of this page the url should be like print.data?id=12 I have taken this in variable $url. Then passed this $url in … Continue reading sending php array variable as link to argument of javascript function

Names of Images Saved in PHP Server Root Are Case Sensitive

I used some images in my PHP scripts. I typed the perfect names of images (eg chair.jpg) in my PHP script. Though in my web root directory, the images are stored by the same name, in output, I didn’t find the images. Later I found that, the image was named like “checked.PNG” in my web root. But in my program, it was “checked.png”. For having … Continue reading Names of Images Saved in PHP Server Root Are Case Sensitive

Inserting form variables into mysql database query string

I was working with a form where I need to insert some form variables in my MySQL database. Inserting data into database is not any problematic issue. But as I had to insert dynamic data contained by the form variables, I faced a little problem. The solution is very very simple! 🙂 the most important thing is — putting the dot(.) and double quotation(“) and … Continue reading Inserting form variables into mysql database query string

Comparing date type variables as form inputs in PHP

I was working with a search module where I needed to work upon the user “date” inputs. The form inputs of dates were string type like “2011-05-06”. I had to confirm few things:
— if both of the input fields [said as $var6 and $var7] are blank or not.
— if first one [$var6] is filled only
— if second date [$var7] is filled only
— user can give two dates in any order. BUT MYSQL ‘BETWEEN’ command [which I used to compare two dates] expects the first argument as early number and second one as big number. so I had to swap two numbers in proper order
here goes some additional needless info,
$var6 = @$_GET[‘date_1’] ;
$var7 = @$_GET[‘date_2’] ;
$wh = “WHERE”; //initializing variable
$cond6 = “”; // initializing variable
Continue reading “Comparing date type variables as form inputs in PHP”

Error: mysql_num_rows() expects parameter 1 to be resource

I was trying to pull some values from Database using PHP. My DB is MySQL. Suddenly I found the error: mysql_num_rows() expects parameter 1 to be resource, boolean given in I was trying to find out the problem. I went through the forum post in Daniweb after googling Finally I fixed it. What was TROLLING is just a [ ‘ ‘ ] sign My query … Continue reading Error: mysql_num_rows() expects parameter 1 to be resource