Jump to content

ajicles

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Everything posted by ajicles

  1. 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
  2. I use WAMP at home and WAMPP at school. I had just finished my website and was uploading it with a few errors. Another error I came across was if entered a sentence like "Don't Eat Yellow Snow" It would work, but using Facebook's SDK if wouldn't make the page for it. It would only make a page that would be titled: "Don' Since the code for it was: <meta property="og:title" content=''<?php echo $row[1]; ?>''/> It would end the sentence at when the quotes were used. To fix that I use double single quotes ' ' not " or ' Problem fixed. Thank you for your help. ~ AJ
  3. Are you sure you saved and uploaded your changes? People sometimes get confused about it I believe I did. I'll check the webserver for any changes. I forgot to upload to FTP it I was FTPING the wrong files. Thank you so much for your help. ~ AJ
  4. It is still returning me an error when I enter single quotes into my form. Here is the website I am using it in that I made: http://likebook.cz.cc And where you enter a sentence with a single quote in it it returns an error. Thanks ~AJ 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 'd always be there... Where are you now? ')' at line 3 PHP: <?php $con = mysql_connect("mysql4.freehostia.com","ajilmf_likebook","*********"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ajilmf_likebook", $con); $result = mysql_query("SELECT * FROM facebook", $con); $num_rows = mysql_num_rows($result); $ID = $num_rows + 1; mysql_select_db("ajilmf_likebook"); $sql="INSERT INTO facebook(ID, post_content) VALUES ('$ID','" . mysql_real_escape_string($_POST[post_content]) . "')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo '<head><META HTTP-EQUIV="refresh" CONTENT="0;URL=http://likebook.cz.cc/like.php?id='.$ID.'"></head><br>'; echo '<center>If your browser does not support redirecting <a href="http://likebook.cz.cc/like.php?id='.$ID.'">click here</a>.</center>'; mysql_close($con) ?>
  5. Thank you very much. I just learned PHP and MYSQL lastweek lol. Learn by online internet videos from Lynda.com
  6. I have fixed the error before when it gave me the error when someone enters a single quote into a field. And it is doing it again for some reason. Thanks AJ. 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 's voice is high listen to usher's.')' at line 3 <?php $con = mysql_connect("mysql4.freehostia.com","ajilmf_likebook","*********"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ajilmf_likebook", $con); $result = mysql_query("SELECT * FROM facebook", $con); $num_rows = mysql_num_rows($result); $ID = $num_rows + 1; mysql_select_db("test"); $sql="INSERT INTO facebook(ID, post_content) VALUES ('$ID','$_POST[post_content]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo '<head><META HTTP-EQUIV="refresh" CONTENT="0;URL=http://likebook.cz.cc/like.php?id='.$ID.'"></head><br>'; echo '<center>If your browser does not support redirecting <a href="http://likebook.cz.cc/like.php?id='.$ID.'">click here</a>.</center>'; mysql_close($con) ?>
  7. Here is a copy of my project files. Its pretty simple. [attachment deleted by admin]
  8. Thank you very much. I just learn php with mysql from Lynda.com. Still newby at it lol.
  9. I have my script: <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("youtube", $con); $sql="INSERT INTO submitvid VALUES('','$_POST[link]','$_POST[title_video]','$_POST[video_description],'$_POST[video_tags]','$_POST[match_type]','$_POST[match_score]','$_POST[match_map]','$_POST[youtube_account]','$_POST[email_address]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Your Video Has Been Submitted!"; mysql_close($con) ?> And I use html form tag to post data into the variable and then that goes into mysql data base. The error is if I use a single quote in the form it returns a 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 've been a good gameplay, but it gets ruined. I thought I'd put it up anyways tho' at line 1 I had to use the single quote in php to call the variable to send it off to the Database. Is there a possible way to fix this? Or is there a way to remove certain characters from the data coming from the form? Thanks ~AJ
  10. Ken could you help me fill out this code? <?php $conn = mysql_connect("localhost", "root", ""); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("youtube")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $sql = "SELECT id as userid, fullname, userstatus FROM sometable WHERE userstatus = 1"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } // While a row of data exists, put that row in $row as an associative array // Note: If you're expecting just one row, no need to use a loop // Note: If you put extract($row); inside the following loop, you'll // then create $userid, $fullname, and $userstatus while ($row = mysql_fetch_assoc($result)) { echo $row["userid"]; echo $row["fullname"]; echo $row["userstatus"]; } mysql_free_result($result); ?> After selecting the database I get confused The three columns that I need to be read are: id link title_video
  11. I have made a PHP Script that allows a user to enter data into a Database and the database recalls the information in a table. I have a problem with Notice: Undefined offset: 9 in E:\wamp\www\video.php on line 61 which calls the data from a row and column. <?php $ID = @$_GET['id'] ; $db_host = 'localhost'; $db_user = 'root'; $db_pwd = ''; $database = 'youtube'; $table = 'submitvid'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); $result = mysql_query("SELECT id,link FROM submitvid WHERE id = '$ID'"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } $row = mysql_fetch_row($result); ?> </center> <table width="755" height="477" border="1"> <tr> <td width="132">Link to file:</td> <td width="607"><?php echo $row[1]; ?></td> </tr> <tr> <td>Title of Video:</td> <td><?php echo $row[2]; ?></td> </tr> <tr> <td>Video Description:</td> <td><?php echo $row[3]; ?></td> </tr> <tr> <td>Video Tags:</td> <td><?php echo $row[4]; ?></td> </tr> <tr> <td>Match Type:</td> <td><?php echo $row[5]; ?></td> </tr> <tr> <td>Match Score:</td> <td><?php echo $row[6]; ?></td> </tr> <tr> <td>Match Map:</td> <td><?php echo $row[7]; ?></td> </tr> <tr> <td>Youtube Account:</td> <td><?php echo $row[8]; ?></td> </tr> <tr> <td>Email Address:</td> <td><?php echo $row[9]; ?></td> </tr> </table> </center> The row is clarified from the URL so in the case the error came up is at row 1. It will show the data from row 1 column 1 and column 2 but wont work with row 1 columns 3-9 for some reason? Could someone help me. Thanks ~ AJ [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.