newbie needs coding help--either parsing err or invalid $END
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
newbie needs coding help--either parsing err or invalid $END
Trying simply to insert into table. Have succeeded in doing this but now want to correct user use of invalid characters. If I'm understanding correctly, Real-escape-string seems to correct these, so I've been trying to figure out how to use it. A short, test code version gives me a syntax error at INSERT VALUES, which--because it still has the single quotes in the text--tells me the real-escape-string didn't work. The code below gives me a parseing error with invalid $END at </body>. Any help appreciated!!!!!!!!!!!!!
-------------------
Insert 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 ' VALUES (UTC_TIMESTAMP,'What's happen' bra?')' at line 1
-------------------
Parse error: syntax error, unexpected $end in /home/powere15/public_html/DB/exercises_insert_record.php on line 94
--------------------------
// Query
$query = sprintf("SELECT * FROM users WHERE ExerciseName='%s' AND ExercisePhoto1='%s'
AND ExercisePhoto1='%s'
AND ExercisePhoto2='%s'
AND Position='%s'
AND TargetMuscles='%s'
AND Instructions1='%s'
AND Instructions2='%s'
AND Instructions3='%s'
AND Issues1='%s'
AND Issues2='%s'
AND Issues3='%s'",
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
mysql_close($link);
print "Record added";
// Free the resources associated with the result set
// This is done automatically at the end of the script
mysql_free_result($result);
?>
<form method="POST" action="exercises_insert_form.html">
<input type="submit" value="Insert Another Record">
</form>
<br>
// Query
$query = sprintf("SELECT * FROM users WHERE ExerciseName='%s' AND ExercisePhoto1='%s'
AND ExercisePhoto1='%s'
AND ExercisePhoto2='%s'
AND Position='%s'
AND TargetMuscles='%s'
AND Instructions1='%s'
AND Instructions2='%s'
AND Instructions3='%s'
AND Issues1='%s'
AND Issues2='%s'
AND Issues3='%s'",
Adding the echo statement immediately following the assignment of values, and before executing the query will display the query to be executed somewhere on your web page. Check the format of the query to confirm that it is what you intended it to be. In particular note that fields containing spaces or special characters must be enclosed in quotes for sql to process them correctly.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.