Insert statement from php script to mysql: Database not reading insert statement -


so insert statement works perfectly. know database connecting because can select information database first 2 statements. know execute_statment3 works because no errors being printed off , when put sql statement inserted way should be. therefore problem lies somewhere communication between script , phpmyadmin. please have been staring @ problem 2 days , going rather crazy.

<?php  session_start();  $hostname = 'localhost'; $username = '####'; $password = '####';   $connection = mysql_connect($hostname, $username, $password)  or die ('connection error!!!');   $database = '####'; mysql_select_db($database);     $uid = $_session['id'];   $album = $_post['albumname'];   $description = $_post['description'];   $filename = $_files["upload_file"]["name"];   $filetype = $_files["upload_file"]["type"]; $filesize = $_files["upload_file"]["size"]; $file_on_server = $_files["upload_file"]["tmp_name"];     if ($filetype == "image/jpeg") {       $file_copy_name = date(m.d.y_h.i.s) . ".jpg";           copy($file_on_server, "uploads/" . $file_copy_name);         print "<br>";       print "<img src = \"uploads/$file_copy_name\">";           print "<br>";       $ret = system("pwd");         $picture = "uploads/$file_copy_name";   }   $execute_statement = "select * imagealbums album = '$album'";   $results = mysql_query($execute_statement) or die ('error executing sql statement!!!');   while($item = mysql_fetch_array($results))   {    $album2 = $item['album']; }  if ($album2 == $album)   {     $execute_statement2 = "select * imagealbums album = '$album'";       $results2 = mysql_query($execute_statement2) or die ('error executing sql statement2!!!');           while ($row2 = mysql_fetch_array($results2)) {           $aid = $row2["albumid"];         }       $execute_statement3 = "insert images (`imageid`, `albumid`, `description`, `extensions`) values ('null', '$aid', '$description', '$file_copy_name')";             ($execute_statement3) or die ('error executing sql statement3!!!');  }   print "<br>"; print "<br>"; print $execute_statement3; print "<br>"; print "<br>"; print $aid; print "<br>"; print "<br>"; print $picture;   ?> 

i using 2 databases script 1 of databases called imagealbums , has 2 columns called albumid , album (albumid being primary key). second table called images , has 4 columns imageid (primary key), albumid (foreign key), description , extensions.

you not running statement

($execute_statement3) or die ('error executing sql statement3!!!'); 

try:

mysql_query($execute_statement3); 

also, make sure escape variables.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -