best way to execute mysql within php script -
im kind of new mysql , trying out scripts.
the 1 thing dont understand is, why (it seems) mysql queries need within php variable.
this example not working:
$username="root"; $password=""; $database="wmt"; $con=mysqli_connect("localhost","root","","wmt"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } else echo "correct"; mysqli_query($con,"load data infile 'top_queries-avtentichno.com-20140627-223259.csv' table discounts fields terminated ',' enclosed '"' lines terminated '\n' ignore 1 rows");
when writing php , want output html this:
<?php code (); ... ?> here goes html without worry escaping! <?php morephp(); ?>
is there similar "trick" execute mysql , avoid putting sql queries in variables?
the double quote within string needs escaped, because string literal enclosed in double quotes.
within context of string literal, this:
enclosed '"'
should replaced this:
enclosed '\"'
so php doesn't see double quote end of string literal.
this isn't sql issue; , it's not issue variables. it's issue string literals in php.
Comments
Post a Comment