Registered: 14 years ago
when you save to a db and there is an ' in the string like "it's", then there is a problem because " and ' in PHP used together create problems (simply stated). So php requires a slash in front of the ' to "escape" it, as it is known.
Google for addslashes
Login is not part of the project. You can add it of you want.
Jwv I entered the same course to my university lol but i didn get any errors because i use the cid instead of cname. When i used the cname on a test page i got an error as well because of that character.
I tried this on my webserver and it worked as follows.
Ok say example im posting $_POST['']; or using a $_REQUEST['']; in my page.
$str = $_REQUEST['course'];
$str2 = str_replace("\'", "*****", $str);
return str_replace('*****', "\'", addslashes($str2));
//I USED THIS TO VIEW WHAT THE VALUE OF $STR IS FOR TESTING
$query = "SELECT * FROM course WHERE cname='$str' ";
When i echo it it displays PC's Maintainance (with the back slash) & result in sql returns PC's Maintainance
That works so try it and let me know. First time i also used a function as this.
Im having problems with my page refresh after deleting or updating a record.
when the user clicks back button, the old data still sits there...
only when you do a manual refresh (f5) does it update...
I've tried different approaches to solving this problem, from cookies to sessions, no luck.
currently im using html to auto refresh the page every 5 seconds or so
<META HTTP-EQUIV="refresh" CONTENT="5">
problem with this is that its very annoying... and the page keeps reload after 5 seconds
Can sum1 please suggest a more effective way to refresh...
Since this isnt part of the prac i will give you my code . You browser is caching the page and the refresh is only refreshing the page, you need the browser to revisit the server and perform your queries etc again.
Add this to the top of the pages.
header("Cache-Control: no-cache, must-revalidate" // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" // Date in the past
Registered: 14 years ago
Well, ajax does this quite brilliantly (but not part of this course
Not sure how you have constructed your pages, but typically you would update something, then provide a message of the success of the update, and <a href links where the use can click to take them back to a previous (or other pages). This forces a reload of the page.
ernistus >>> With a delete you can take the user baback to a cenral location. With a student update i recall the display page to reload the students info.
MuhammadA >>> Hi there, hope you are well. Thanks for the help. I found that where I was passing the data through HTMLspecialchars I did not seem to have the problem. I wonder if it treats the single quote in the same manner as addslashes.
Mac >>> Is it possible that we could download all the pracs in one large zip file after everyone has been marked so that we can see how the other students saw the prac.
Also Mac, could you recomend a good php forum that one could join after the course.