Current location: Hot Scripts Forums » Programming Languages » PHP » mySQL database;


mySQL database;

Reply
  #1 (permalink)  
Old 09-17-04, 09:16 AM
Dion's Avatar
Dion Dion is offline
Newbie Coder
 
Join Date: Jun 2004
Location: NL
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
mySQL database;

Hi,
I've had a link exchange page hosted on my own pc. But now I have a free host. Everything is working correctly except for the url adding. This is the script which I use:
PHP Code:

01: <html>

02: 
03: <head>
04: 
05: <title>Untitled Document</title>
06: 
07: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
08: 
09: </head>
10: 
11: <body>
12: 
13: <?php
14

15: include_once ("./settings.php");
16
17
18
19$user $_POST["naam"];
20
21$link $_POST["link"];
22
23
24
25$dbh mysql_connect($hostname$username$password) or die("Unable to connect to MySQL");
26
27$selected mysql_select_db("$base",$dbh) or die("database error");
28
29
30
31:
32$sql "INSERT INTO `$basesites` ( `id` , `naam` , `link` ) " " VALUES ( '', '$user', '$link' );" " "
33
34mysql_query($sql);
35
36$res mysql_affected_rows();
37
38
39
40: if($res 0) {
41
42$succes=1//succesfully added to the database
43
44: } 
45
46: else {$succes=0;}    
47
48: if ($succes == 1){print "registration complete  " "$res";}
49
50: else {print "<P>ERROR during registering: <br> " .  mysql_error() . "</P>";}
51
52
53
54mysql_close($dbh);?>
55: 
56: <a href="index.php"><br>click page</a>
57: 
58: </body>
59: 
60: </html>
On another page I've got a little form where the $link and the $name are specified.
The problem is when I try to register I get this error:
"ERROR during registering:
You have an error in your SQL syntax near '; ' at line 1"

But I don't see the error, maybe some of you can help me with this one
__________________
just a n00b trying to learn php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-17-04, 09:37 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
here is the error: (or should be atleast)

PHP Code:

32$sql "INSERT INTO `$basesites` ( `id` , `naam` , `link` ) " " VALUES ( '', '$user', '$link' )"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-17-04, 09:39 AM
Dion's Avatar
Dion Dion is offline
Newbie Coder
 
Join Date: Jun 2004
Location: NL
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
THANK YOU, it's working great now
__________________
just a n00b trying to learn php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 02:41 AM
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 03:22 AM
Error while creating database (Errornumber 2002: "Can't connect to local MySQL server lylesback2 PHP 5 04-11-04 02:37 PM
Importing to a mysql database via php gulfan PHP 1 01-23-04 05:44 PM
how to import a png file from mysql database. rani PHP 1 01-16-04 04:34 AM


All times are GMT -5. The time now is 11:55 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.