hit another brick wall, mysql :S

Reply

Join Date: Nov 2005
Posts: 3
Reputation: terence sharp is an unknown quantity at this point 
Solved Threads: 0
terence sharp terence sharp is offline Offline
Newbie Poster

hit another brick wall, mysql :S

 
0
  #1
Dec 3rd, 2005
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]
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 902
Reputation: chrisbliss18 is an unknown quantity at this point 
Solved Threads: 23
chrisbliss18's Avatar
chrisbliss18 chrisbliss18 is offline Offline
Posting Shark

Re: hit another brick wall, mysql :S

 
0
  #2
Dec 3rd, 2005
There are a couple issues here:
  1. 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:
    1. INSERT INTO camera (name, type, link) VALUES ('noob cam 2', 'webcam', 'www.alinktothecam.com');
  2. 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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC