this is my table im trying to create in phpmyadmin. is there a way of inserting the insert statement
create database poll;
use poll;
create table poll_results (
candidate varchar(30),
num_votes int
);
insert into poll_results values
('John Smith', 0),
('Mary Jones', 0),
('Fred Bloggs', 0)
;
grant all privileges
on poll.*
to poll@localhost
identified by 'poll';
and this is my poll.php page. is there another way to connect to the database as i can't seem to get it working.
// log in to database
if (!$db_conn = @mysql_connect('localhost', 'poll', 'poll'))
{
echo 'Could not connect to db<br />';
exit;
};
@mysql_select_db('poll');
if (!empty($vote)) // if they filled the form out, add their vote
{
$vote = addslashes($vote);
$query = "update poll_results
set num_votes = num_votes + 1
where candidate = '$vote'";
if(!($result = @($query, $db_conn)))
{
echo 'Could not connect to db<br />';
exit;
}
};