smiles Posted March 24, 2007 Share Posted March 24, 2007 Here is the code <?php$php = ".php";if (($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/jpg")&& ($_FILES["file"]["size"] < 200000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; $name = $_FILES["file"]["name"]; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: '.mysql_error()); } // select database cms mysql_select_db("cms",$con); // choose the first database $sqlstr = "INSERT INTO cmsdata (imagelink) VALUES ('".$name."')"; mysql_query($sqlstr); $files= $_FILES["file"]["name"].$php; echo $files; fopen($files,"w"); file_put_contents($files,"hello world!"); mysql_select_db("myloves124_images",$con1); // choose the second database *it says error here* $sql = "CREATE TABLE $files ( Comment longtext )"; mysql_query($sql,$con1); // and *error* here echo "<br /><a href='".$files."'>View</a>"; } } }else { echo "Invalid file"; }?> How can I select 2 database in these code like above ?thanks ! Link to comment Share on other sites More sharing options...
justsomeguy Posted March 26, 2007 Share Posted March 26, 2007 You don't have a connection called $con1. Either make a new connection or re-use the existing one. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now