php - varchar datatype doesnt show result for long entries -


this question has answer here:

i developing application monitor ip adress activity. using lamp stack on ubuntu 12.04. in mysql database, created table 2 columns , ip , mac, both have datatype varchar. put data table , when use select * table, result

 ip                    mac  1                       2 1.10.0.0.43       00 19 78 d3 r5 ed 8.9                 32.22 

the middle row how expect entries come switch like.the first , 3rd put them testing purposes.

i have written php code matching , retrieval , follows

<?php      $var = $_request['ip'];         echo $var;      mysql_connect( "localhost", "root", "mysql" ) or die("unable connect database");     mysql_select_db( "syslog" );      $result = mysql_query( "select ip,mac arp_table ip=$var"  );      $row = mysql_fetch_row( $result );      print_r( $row );  ?> 

when enter 1 on form ,the result ok, in form of 1 array([0]=>1[1]=>2) , when enter 8.9, output ok well. when enter 1.10.0.0.43, output echo of variable, no array retrieved. idea of why so?

that because not using quotes around $var. when using strings in sql need quoted such as:

select ip,mac arp_table ip='$var'; 

if not quoted value interpreted mysql , automatically converted (for example) integer because value looks integer 1 / 2 ... etc..


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -