Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Making It All Work

June 23, 2000

Now its time to add the stuff that makes it all work. I can't really explain what we are using below, so I suggest you go to the PHP website and study the main elements used below, mysql_connect() and mysql_select_db(). It may be a good idea to go to the MySQL site and learn how to insert, delete, modify and anything else you want to fill your brain with.

	
<?php 
	

if ($submit) {

$db = mysql_connect( "$localhost", "$joesauto", "$password");

mysql_select_db( "$joesauto",$db);

$sql = "INSERT INTO joesauto (year,make,model,price,picture_name) ".
"VALUES ('$year,$make,$model,$price,$picture_name')";

exec( "cp $picture /full/path/to/joesauto/images/$picture_name");

echo "year: $year<br>\n";
echo "make: $make<br>\n";
echo "model: $model<br>\n";
echo "price: $price<br>\n";
echo "temp file: $picture<br>\n";
echo "file name: $picture_name<br>\n";
echo "file size: $picture_size<br>\n";
echo "file type: $picture_type<br>\n";
echo "<br>\n";
echo "<img src=images/$picture_name><br>\n";

}

?>

After you add the above code to the add_data.php3 page, (right below the closing form tag would work great), you'll need to change a few things to work with your database. It should all be pretty straight forward, you just need to change $your_username, $your_password and you'll need to specify the full path to where your images directory is. You also need to make sure that the image directory is CHMOD 777.

Now everything should be set and you're ready to upload it to the server to see if everything works. The next lesson in this tutorial will show you how to view the data, and I will show you how to do more stuff in lessons to follow.

My name is William Samplonius and I am web designer for enduradezine. I hope this helped you, but don't email me your questions because I know just as much as you do.

Inserting the Data Into the Database
PHP, MySQL and Images


Up to => Home / Authoring / Languages / PHP / Images




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers