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!

  1. Go to the LAN settings (in Chrome : Tools-> Options-> Under the hood -> Change Proxy setting -> LAN Setting)
  2. There will be a checkbox for "Bypass proxy server for local address"
  3. Tick the checkbox.

Thanks to : this link

You have an error in your SQL syntax; check the manual for the right syntax to use near ‘check

I was working with an SQL syntax today and found an error which was like :

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘check) VALUES (‘YES’)’ at line 1

I was trying again and again checking DB connection and fixing other things but the error were not being resolved. I was using very simple SQL query which was like the following :

$query = "INSERT INTO test1(check) VALUES ('YES')";

so what was my mistake? I later realized, it is about RESERVED WORDS of mysql. CHECK is a word which is reserved by MySQL. I used CHECK as a column name of my Table, which was causing the error.

If you have similar errors, Have a look of MySQL RESERVED WORD list from this link.

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()


<script type="text/javascript">// 
function popitup(url) {
       newwindow=window.open(url,'name','scrollbars,height=500,width=500','scrollbars');
       if (window.focus) {newwindow.focus()}
       return false;
}
</script>

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 characteristics of the popup window. they will have to be in a single quotation mark and distinguished by comma(,) For example, see the above window.open function window.open(url,’name’,'scrollbars,height=500,width=500′). Here after url, name, all other scrollbars, height, width are taken in the single quotation marks.

More functionality can be added in this THIRD part of the argument of window.open() function:

dependent
directories
fullscreen
location
menubar
resizable
scrollbars
status
toolbar
top=200
left=400
width=200
height=200
screenX=400
screenY=200


 <a onclick="return popitup('popupex.html')" href="popupex.html">Link to popup</a>

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.

 <?php $url = "print_data.php?id=".$row_rstest['id']; ?>

Then passed this $url in function popitup(). The important thing is to put the sign (‘) around $url variable. Otherwise the function didn’t work for link.

  <?php echo "<a href=\"\" onClick=\"return popitup('$url') \">Click here to open a pop up window</a>"; ?>
          

Hide Print Button While Printing A Page

I was in a problem today. I tried to print a page which I developed in PHP. I inserted a PRINT button in it. but while I was using JS function window.print() which was printing my PRINT button too! So I took the help of CSS to solve the problem. just used 3 line codes before the button. I named the button id as “btnPrint” and in CSS it was set as display:none. So while the page was being printed, the button was not!

You can follow the code! it’s simple :)



<style type="text/css">
@media print {
input#btnPrint {
display: none;
}
}
</style> 


<input type="button" id="btnPrint" onclick="window.print();" value="Print Page" />

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 lower case in my code [png] but main image was in upper case [PNG], I didn’t find the image in output screen after loading.

This scenario doesn’t happen always. It varies! I found output the other time though the extension was different [one was in upper case and the other in lower case]

Simple JavaScript code to print a page


<SCRIPT LANGUAGE="JavaScript"> 
if (window.print) {
document.write('<form><input type=button name=print value="Print" onClick="window.print()"></form>');
}
</script>


Or to put a hyperlink on an image, the following code is nice:


<a href="javascript:window.print()"><img src="images/forward.png"></a>

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! :)


//variables will contain the data stored in the form variable id, hod, status
$soid = $_POST['id']; 
$employeeid = $_POST['hod'];	
$statusto = $_POST['status'];
	
// the is the SQL query to insert into database

$sql = "INSERT INTO `service_order`.`change_log` (`service_order_id`, `employee_id`, `changed_to`) VALUES ('".$soid."', '".$employeeid."', '".$statusto."')";

the most important thing is — putting the dot(.) and double quotation(“) and single quotation(‘) around the variables $soid, $employeeid and $satusto

For not using these three symbols properly, I found errors in my program

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
Read the full post »

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 which was giving error:

$query = "select * from service_order where account_manager_id = $var AND primary_connection_media= $var2";

When I fixed the error by putting ” around the variables, the query is:

$query = "select * from service_order where account_manager_id = '$var' AND primary_connection_media= '$var2'";

Follow

Get every new post delivered to your Inbox.