Scriptbanger
10-21-2006, 12:20 AM
:o Okay, it's been awhile but I shouldn't have forgotten the basics. Hopefully I am posting in the right section.
I have a very simple form [4 fields] and I need to put that data into a database using PHP and MySQL. And all I am getting is an error. Please, somebody tell me what I have done wrong. I am following a tutorial and have done everything like I was shown.
Here is the error I am getting: Warning: mysql_select_db (http://php.net/mysql_select_db)(): supplied argument is not a valid MySQL-Link resource in . . .\media_interface.php on line 10
In the head section of my document:
<?php
$db_host = "****";
$db_user = "****";
$db_pwd = "****";
$db_name = "multimediadb";
mysql_connect (http://php.net/mysql_connect)($db_host, $db_user, $db_pwd);
mysql_select_db (http://php.net/mysql_select_db)($db_name);
?>
In the body of my form page:
<?php
if (!isset (http://php.net/isset)($_POST['submit'])) {
?>
<form name="mediaPost" id="mediaPost" action="" method="post">
<table align="center" cellspacing="5" cellpadding="10" border="0" class="noborder" style="background-color:#eeeeee;">
<tr><td class="border">
<b>Media Format</b><br>
<input type="radio" name="type" id="type" value="videolocal" class="radio"> Video <small>[FTP Local]</small> |
<input type="radio" name="type" id="type" value="videoyoutube" class="radio"> Video <small>[YouTube]</small> |
<input type="radio" name="type" id="type" value="slideshow" class="radio"> Slideshow |
<input type="radio" name="type" id="type" value="audio" class="radio"> Audio
</td></tr>
<tr><td class="border">
<b>File Location</b> <small>[Filename -OR- YouTube URL]</small><br />
<input type="text" name="filename" id="filename" style="width:600px;">
</td></tr>
<tr><td class="border">
<b>Descriptive Name</b> <small>[Short Description]</small><br />
<input type="text" name="name" id="name" style="width:600px;">
</td></tr>
<tr><td class="border">
<b>Caption</b> <small>[Long Text]</small><br />
<textarea name="caption" id="caption" style="width:600px; height:100px;"></textarea>
</td></tr></table>
<div style="font-size:8pt;"> </div>
<div align="center"><input type="submit" value="Post Media" class="button"> <input type="reset" value="Reset Form" class="button"></div>
</form>
<?php
} else {
$filename = $_POST[‘filename’];
$name = $_POST[‘name’];
$caption = $_POST[‘caption’];
$type = $_POST[‘type’];
mysql_query (http://php.net/mysql_query)("INSERT INTO `multimediadb` (filename, name, caption, type) VALUES (‘$filename’, ‘$name’, ‘$caption’, ‘$type’)");
echo "Success! Your media post was successful! If you followed the instructions you should now be able to access your file.";
}
?>
I have a very simple form [4 fields] and I need to put that data into a database using PHP and MySQL. And all I am getting is an error. Please, somebody tell me what I have done wrong. I am following a tutorial and have done everything like I was shown.
Here is the error I am getting: Warning: mysql_select_db (http://php.net/mysql_select_db)(): supplied argument is not a valid MySQL-Link resource in . . .\media_interface.php on line 10
In the head section of my document:
<?php
$db_host = "****";
$db_user = "****";
$db_pwd = "****";
$db_name = "multimediadb";
mysql_connect (http://php.net/mysql_connect)($db_host, $db_user, $db_pwd);
mysql_select_db (http://php.net/mysql_select_db)($db_name);
?>
In the body of my form page:
<?php
if (!isset (http://php.net/isset)($_POST['submit'])) {
?>
<form name="mediaPost" id="mediaPost" action="" method="post">
<table align="center" cellspacing="5" cellpadding="10" border="0" class="noborder" style="background-color:#eeeeee;">
<tr><td class="border">
<b>Media Format</b><br>
<input type="radio" name="type" id="type" value="videolocal" class="radio"> Video <small>[FTP Local]</small> |
<input type="radio" name="type" id="type" value="videoyoutube" class="radio"> Video <small>[YouTube]</small> |
<input type="radio" name="type" id="type" value="slideshow" class="radio"> Slideshow |
<input type="radio" name="type" id="type" value="audio" class="radio"> Audio
</td></tr>
<tr><td class="border">
<b>File Location</b> <small>[Filename -OR- YouTube URL]</small><br />
<input type="text" name="filename" id="filename" style="width:600px;">
</td></tr>
<tr><td class="border">
<b>Descriptive Name</b> <small>[Short Description]</small><br />
<input type="text" name="name" id="name" style="width:600px;">
</td></tr>
<tr><td class="border">
<b>Caption</b> <small>[Long Text]</small><br />
<textarea name="caption" id="caption" style="width:600px; height:100px;"></textarea>
</td></tr></table>
<div style="font-size:8pt;"> </div>
<div align="center"><input type="submit" value="Post Media" class="button"> <input type="reset" value="Reset Form" class="button"></div>
</form>
<?php
} else {
$filename = $_POST[‘filename’];
$name = $_POST[‘name’];
$caption = $_POST[‘caption’];
$type = $_POST[‘type’];
mysql_query (http://php.net/mysql_query)("INSERT INTO `multimediadb` (filename, name, caption, type) VALUES (‘$filename’, ‘$name’, ‘$caption’, ‘$type’)");
echo "Success! Your media post was successful! If you followed the instructions you should now be able to access your file.";
}
?>