I'm having trouble passing a variable($num) to my working MYsql db. The commented out sql$ works with the explicit 203-263-0011 passed directly. The working sql$ string was generated thru the mysqladmin tool. Thank You for any advice anyone may have.
~Steve
Here is the code:
<?php
$name = $_REQUEST['Name'] ;
$address = $_REQUEST['Address'] ;
$num = "203-263-0011";
$num = addslashes($num);
$username = "user";
$password = "pass";
$host="host";
$database="datatrac_test";
$conn = mysql_connect($host,$username,$password);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db($database);
if (!$db_selected) {
die('Could not select database: ' . mysql_error());
}
mysql_select_db($database, $conn);
Working:
/* $sql = 'UPDATE `cust` SET `telephone1` = \' "203-264-0013"\' WHERE CONVERT(`lookupname` USING utf8) = \'"Carmen Anthony Fishhouse"\' ;'; */
Not working:
$sql = 'UPDATE `cust` SET `telephone1` = \'$num\' WHERE CONVERT(`lookupname` USING utf8) = \'"Carmen Anthony Fishhouse"\' ;';
$result = mysql_query($sql);