Inverno Posted October 24, 2006 Share Posted October 24, 2006 I'm new to php (and coding in general), as my code should make apparent. However I'm pretty sure at least the code outside of my <?php tag should be working, but it's not. Also, the php isn't doing anything either; no die messages display, no changes to the database are made. Can someone tell me where I've messed up?[code]<head><title>Movie Added</title></head><body><p> test</p><?php//define variables$mdesc = $_POST['mdescription'];$mname = $_POST['mname'];$genre = $_POST['genre'];$rating = $_POST['rating'];$dlast = $_POST['dlastname'];$dfirst = $_POST['dfirstname'];$alast = $_POST['alastname'];$afirst = $_POST['afirstname'];//connect to server$con = mysql_connect("localhost","username","password");if (!$con) { die('Could not connect: ' . mysql_error()); }//open databasemysql_select_db("dbname", $con) or die("no db found");//the movie script//add movie info to table$query="INSERT INTO movie (name, genre, description) VALUES ("$mname", "$genre", "$mdesc")"or die('Error!' . mysql_error());mysql_query($query);//the director script//add director info to table$query1="INSERT INTO director (lastname, firstname) VALUES ("$dlast", "$dfirst")" or die("Error!");mysql_query($query1);//the actor script//add actor info to table$check= if (mysql_query("SELECT actor.firstname, actor.lastname FROM actor WHERE actor.lastname="$alast" AND actor.firstname="$afirst""); else mysql_query("INSERT INTO actor (lastname, firstname) VALUES ("$alast", "$afirst")");/* possibly improved on? $query="INSERT INTO actor (lastname, firstname) VALUES (\"$_POST[alastname]\",\"$_POST[afirstname]\")"*/mysql_query($check);//the rating script//define movieid$result = mysql_query("SELECT movies.movieid FROM movies WHERE movies.name = "$mname"") or die('Error!' . mysql_error());//add rating info to table$query2= mysql_query("INSERT INTO rating (rating, movieid) VALUES ("$rating", "$result")") or die('Error!' . mysql_error());mysql_query($result);mysql_query($query2);//tie director to the movie//find movieid$mid = mysql_query("SELECT movies.movieid FROM movies WHERE movies.name = "$mname"") or die('Error!' . mysql_error());//find dirid$did = mysql_query("SELECT director.dirid FROM director WHERE director.lastname = "$dlast" AND WHERE director.firstname = "$dfirst")" or die('Error!' . mysql_error());//combine results$add = mysql_query("INSERT INTO directormovie (directorid, movieid) VALUES ("$did", "$mid")") or die('Error!' . mysql_error());mysql_query($mid);mysql_query($did);mysql_query($add);//modify actor table//find actor id$aid = mysql_query("SELECT actor.actorid FROM actor WHERE actor.lastname = "$alast" AND WHERE actor.firstname = "$afirst"") or die('Error!' . mysql_error()); //tie actor and movie together$add1 = mysql_query("INSERT INTO actormovie (actorid, movieid) VALUES ("$aid", "$mid")") or die('Error!' . mysql_error());mysql_query($aid);mysql_query($add1);mysql_close($con);?><p>test 2.</p></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24903-nothing-will-print/ Share on other sites More sharing options...
Zane Posted October 24, 2006 Share Posted October 24, 2006 Well for one[code]it's supposed to be$query="INSERT INTO movie (name, genre, description) VALUES ('$mname', '$genre', '$mdesc')";$result = mysql_query($query)or die('Error!' . mysql_error());[/code]not[quote]$query ="INSERT INTO movie (name, genre, description) VALUES ("$mname", "$genre", "$mdesc")"or die('Error!' . mysql_error());mysql_query($query);[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/24903-nothing-will-print/#findComment-113504 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.