How embarrassing... the variables worked perfectly fine, it was me, who had made one column int instead of varchar, and the variable I got was a string.
Now everything works perfectly.
I'm still doing something wrong. I've made a new page instead of svar.html, namely svara.php, and written the following:
in enskildtrad.php:
session_start();
if (isset($_SESSION['userid'])) {
$tradid = $_GET["id"];
$_SESSION['myvar']=$tradid;
...
print "<a...
2 problems:
I can't write <a href=\"svar.html?id=\">, and
I already have a session at the top, to keep track of the logged-in user, and to sessions together on one page don't work.
Thank you, vacunita, that works perfectly. One last thing then - when I want people to be able to answer the thread, I have a link on enskildtrad.php to a page called svar.html,l which in turn consists a form with action=svar.php... and I want this svar.php to also keep the id-variable "in...
It was supposed to take the threadid that had been clicked on and pass that to the new page, where I could compare the passed-on-value with the threadid in the database's table thread.
I saw that line on another site, and if I remove the (int) the result is that the error message claims...
I'm making a forum with php and mysql. I have a webserver and a database (WAMP).
Once a user is logged in, he/she can see the titles of the threads on a page called index_online_php. Each thread is a link to another page called enskildtrad.php, where I want to print the thread they have clicked...
In answer to Da Butcher:
1: SQL Injection - good point. Will fix this once I've got the basics to work.
2: You dont remove tags and such (look up strip_tags()) - where should I remove tags and why?
3: You dont check if variables are filled (eg. it can post in no cat?). - good point again. I...
You're so right - I had set forfattare as INT. I replaced that with VARCHAR and added to the login.php that the username used to log in should be the userid.
Now it works. posts are recorded with the logged in member as its author.
Thank you all for your help, I appreciate it.
Tried your suggestion. It enters the data into the db, but it places a 0 in the column forfattare.
I tried replacing this file post.php with another one, test.php, with this code:
<?php
session_start();
// check session variable is set
if (isset($_SESSION['userid'])) {
// if set, greet by...
Hello,
I have some trouble getting a posting-script to work for a forum I'm developing. I know the sessions work, I've tried that, but nothing gets posted into the db. I suspect the lines
$user = $_SESSION['userid'];
and
$query = "INSERT INTO thread(title, text, datum, Kat, forfattare)...
Ah - NOW I see the problem! I did change "your" to the name of my file, but I thought I had to change 0 to the frame label. You're completely right, it works perfectly now.
Thank you so much, you've solved a problem I've been working on for months! *hugs*
Hello,
I'm working on a flash-based memorygame, and my teacher asked me to add a button so that a player who gets tired in the middle of a game can go back to the Start page and choose a new level of difficulty.
You can test the game here: http://pollyjuice.se/Skola/memoryspel.swf
I'm using...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.