| | |
hit another brick wall, mysql :S
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2005
Posts: 3
Reputation:
Solved Threads: 0
i have made a script that adds to a tabel in mysql, one problem is, even though it echos that it worked. it doesnt add them 
[php]
<?php
$dbhost = 'localhost';
$dbuser = 'tezzana_cams';
$dbpass = '**********';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
echo ("Connected...");
$dbname = 'tezzana_camera';
mysql_select_db($dbname);
echo ("Selected...");
mysql_query("INSERT INTO `camera` (`id`, `name`, `type`, `link`) VALUES (' ', 'noob cam 2', 'webcam', 'www.alinktothecam.com');");
echo ("Added...");
mysql_close();
echo ("Closed.");
?>
[/php]

[php]
<?php
$dbhost = 'localhost';
$dbuser = 'tezzana_cams';
$dbpass = '**********';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
echo ("Connected...");
$dbname = 'tezzana_camera';
mysql_select_db($dbname);
echo ("Selected...");
mysql_query("INSERT INTO `camera` (`id`, `name`, `type`, `link`) VALUES (' ', 'noob cam 2', 'webcam', 'www.alinktothecam.com');");
echo ("Added...");
mysql_close();
echo ("Closed.");
?>
[/php]
There are a couple issues here:
- You don't need to put single-quotes around the table name or the field names. Most table formats do not allow empty id fields. If you want it to autofill the number and you have the table set up to do so, just omit the id field from the query. It should look like this: PHP Syntax (Toggle Plain Text)
- INSERT INTO camera (name, type, link) VALUES ('noob cam 2', 'webcam', 'www.alinktothecam.com');
- Your program doesn't do any checking to see if the query actually works, it just prints "Added...". So of course it's going to tell you that it worked every time, you told it to.
Did we help you? Did we miss the point entirely? Update your thread and let us know.
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
![]() |
Similar Threads
- simple c++ program (any help would be greatly appreciated) (C++)
- FireFox not showing CSS in Strict Mode (HTML and CSS)
- Mysql Php Image Help Please!!! (MySQL)
- Php Mysql Image Help Please!!! (PHP)
- I hit a brick wall-- time complexity problem (Computer Science)
- password problem with system 10.3! (OS X)
- Problem with new system (Troubleshooting Dead Machines)
- Overclocking 2600+.. help? (Motherboards, CPUs and RAM)
Other Threads in the PHP Forum
- Previous Thread: Help - Looking for a web hosting directory script. Any recommandations !?
- Next Thread: Installation of PHP on Windows
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





