spork
June 9th, 2002, 11:56
iīve gotten rather decent at php lately so i figured it was time to get more educated in handeling mysql databases... unfortunately the progress is slow since i almost never have more than 20 uninterupted minutes to spend on anything... anyway, what did i miss with this simple query? it returns the error "You have an error in your SQL syntax near '' at line 1" but i donīt really know what i missed...
i just tried changing "after" to "first" and then it worked... strange... is after not a valid location for a column?
<?php
$db = "test2";
$dbhost = "localhost";
$dbusername = "";
$dbpassword = "";
$table = "test";
$column = "url";
$conn = mysql_connect("$dbhost", "$dbusername", "$dbpassword") or
die("Count not connect to database");
echo "connected to database.<br>";
mysql_select_db($db) or
die ("Could not select database");
echo "selcted database $db.<br>";
$query = "alter table $table add column $column varchar(40) null after";
mysql_query ($query) or
die (mysql_error());
echo "added column $column";
?>
i just tried changing "after" to "first" and then it worked... strange... is after not a valid location for a column?
<?php
$db = "test2";
$dbhost = "localhost";
$dbusername = "";
$dbpassword = "";
$table = "test";
$column = "url";
$conn = mysql_connect("$dbhost", "$dbusername", "$dbpassword") or
die("Count not connect to database");
echo "connected to database.<br>";
mysql_select_db($db) or
die ("Could not select database");
echo "selcted database $db.<br>";
$query = "alter table $table add column $column varchar(40) null after";
mysql_query ($query) or
die (mysql_error());
echo "added column $column";
?>