note 104095 added to function.mysql-db-query

From: Date: Sun, 22 May 2011 21:47:06 +0000
Subject: note 104095 added to function.mysql-db-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-179942@lists.php.net to get a copy of this message
/* mmm, it seems that the example don't show the function mysql_db_query, but mysql_query. Lets see it properly done: */ // on this one, we connect to database and recover some rows <?php bd=mysql_connect("MySQL_HOST","Admin","******"); if(!$bd) { die("Error, connection failed"); } else { $select = mysql_db_query("Hollywood","SELECT * FROM movies"); while($object=mysql_fetch_object($select)) { echo "Id Movie: ".$object->Id."."; echo "Title: ".$object->Title."."; echo "Director: ".$object->Director."."; } } mysql_close($bd); ?> // on this one, we connect to database and execute a sentence (INSERT/UPDATE/DELETE) <?php $id = $_POST["IdMovie"]; $title = $_POST["TitleMovie"]; bd=mysql_connect("MySQL_HOST","Admin","******"); if(!$bd) { die("Error, connection failed."); } else { if(!mysql_db_query("Hollywood","UPDATE movies SET Title='$title' WHERE Id='$id'")) { die("Error, movie not updated."); } } mysql_close($bd); ?> ---- Server IP: 130.206.1.5 Probable Submitter: 46.222.6.61 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-db-query.php Edit -- https://master.php.net/note/edit/104095 Del: integrated -- https://master.php.net/note/delete/104095/integrated Del: useless -- https://master.php.net/note/delete/104095/useless Del: bad code -- https://master.php.net/note/delete/104095/bad+code Del: spam -- https://master.php.net/note/delete/104095/spam Del: non-english -- https://master.php.net/note/delete/104095/non-english Del: in docs -- https://master.php.net/note/delete/104095/in+docs Del: other reasons-- https://master.php.net/note/delete/104095 Reject -- https://master.php.net/note/reject/104095 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179942) next »