ajicles Posted June 30, 2010 Share Posted June 30, 2010 Sorry to bug you guys again but I have another error: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like, ip_address) VALUES ('','66.79.239.225')' at line 1 I am trying to make a rating system for a website and I am having a very hard time trying to understand why it is not working. I have set the database column to varchar which should store the ip address and keeps returning an error. Source: <?php $IP = $_SERVER['REMOTE_ADDR']; $LIKE = @$_GET['like_vid'] ; echo $IP; echo $LIKE; $con = mysql_connect("****","****","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ajilmf_likebook"); $sql="INSERT INTO lgu(like, ip_address) VALUES ('$LIKE','$IP')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con) ?> And another problem is where I am trying to use a menu to post data to another column (like). And it is not echoing back to me on the PHP side of it. And I have no idea why the html form is not working.. HTML Form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form action="lgu.php" method="post"> Like This Video: <select name="like" size="2" id="like"> <option value="yes" selected="selected">yes</option> <option value="no">no</option> </select> <input name="submit" type="submit" id="submit" value="Submit" /> <label for="like"></label> </form> </body> </html> lgu.php is the php source above. All I am trying to do is record either yes or no and the ip address. I could of used a Boolean for true or false but I don't wanna get myself confused lol. Thanks ~ AJ Quote Link to comment https://forums.phpfreaks.com/topic/206256-another-error/ Share on other sites More sharing options...
travo1992 Posted June 30, 2010 Share Posted June 30, 2010 For the sql error, Im thinking it could be 1 of these: 1: there should be a space between your table and your rows 2: like is a reserveed keywork, you should use quotes Try INSERT INTO lgu (`like`, `ip_address`) VALUES ('$LIKE','$IP') For the form, you dont use the same vaiable name, and you have specified post in the form. Try $LIKE = $_POST['like']; Quote Link to comment https://forums.phpfreaks.com/topic/206256-another-error/#findComment-1079046 Share on other sites More sharing options...
harristweed Posted June 30, 2010 Share Posted June 30, 2010 There is a strong possibility that 'like' is a reserved word in MYSQL try changing the field name. Quote Link to comment https://forums.phpfreaks.com/topic/206256-another-error/#findComment-1079076 Share on other sites More sharing options...
ajicles Posted June 30, 2010 Author Share Posted June 30, 2010 Alright, I try that guys. Thanks ~ AJ Quote Link to comment https://forums.phpfreaks.com/topic/206256-another-error/#findComment-1079245 Share on other sites More sharing options...
ajicles Posted June 30, 2010 Author Share Posted June 30, 2010 Thanks alot it worked Full Texts like_video ip_address Edit Delete yes 66.79.239.225 Works perfectly. Now I just go make it make a new table for each video that is posted. So its going to be a huge database, I'd say about 200-300 tables with about 2000 rows each at the most. Most likely be less than that. Thanks ~AJ Quote Link to comment https://forums.phpfreaks.com/topic/206256-another-error/#findComment-1079252 Share on other sites More sharing options...
travo1992 Posted June 30, 2010 Share Posted June 30, 2010 Why do you need so many tables? You can get away with one, just add a video id column Quote Link to comment https://forums.phpfreaks.com/topic/206256-another-error/#findComment-1079397 Share on other sites More sharing options...
ajicles Posted July 1, 2010 Author Share Posted July 1, 2010 Well there is going to be a lot of videos in the data base and having to log each ip for each video so people can't vote more than once per video. So I though I could have a master table called video_index and the video viewing page will have a id on the end of the url like: http://mywebsite.com/video.php?id=1 and it adds the under to a variable with video_ before the number so its: video_1 and video_1 is a table and video_1 would have logged the ips of people who voted for that video. ~ AJ Quote Link to comment https://forums.phpfreaks.com/topic/206256-another-error/#findComment-1079860 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.