5 replies [Last post]
rmcivo1
Offline
Enthusiast
Shropshire | Shrewsbury
Last seen: 10 years 20 weeks ago
Shropshire | Shrewsbury
Joined: 2003-12-05
Posts: 115
Points: 0

I am making a questionnaire that records peoples results, here is my code:

Quote:

if ($question1=="Rees Andrew McIvor" || $question1=="rees andrew mcivor" || $question1=="Rees Andrew Mcivor") {
echo "<tr><td><strong>Question 2: </strong>Well done!! Correct Answer</td></tr>" &&
$sql = "INSERT INTO logic_questionnaire SET
name ='$name',
answers ='1 out of 11'";
} else {
echo "<tr><td><strong>Question 1: </strong>Sorry Wrong Answer</td></tr>" &&
$sql = "INSERT INTO logic_questionnaire SET
name ='$name',
answers ='0 out of 11'";
}

Can you see from the code why it aint inserting the information?
Thanks

The Cyber World

Tags:
dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 5 years 26 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

Can anybody help?

What's the && for? I wouldn't have those there, just a semicolon.

I assume the mysql_query($sql) statement is elsewhere?

What's the error message?

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

rmcivo1
Offline
Enthusiast
Shropshire | Shrewsbury
Last seen: 10 years 20 weeks ago
Shropshire | Shrewsbury
Joined: 2003-12-05
Posts: 115
Points: 0

Can anybody help?

I have no errors, I aint included the mysql_query($sql) statment, I have used it before. But I dont konw how to go about it. Could you help?

The Cyber World

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 5 years 26 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

Can anybody help?

You need something like:

$link = mysql_connect("localhost", $user, $password)
	or die("Could not connect to server");

mysql_select_db($database)
	or die("Could not select database \"".$database."\" - ".mysql_error());

to initialise the link to the MySQL server.

Then you can run as many mysql_query($sql)'s as you like.

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

rmcivo1
Offline
Enthusiast
Shropshire | Shrewsbury
Last seen: 10 years 20 weeks ago
Shropshire | Shrewsbury
Joined: 2003-12-05
Posts: 115
Points: 0

Yeah I understand

Yeah I understand that.. I get no errors, sorry I didnt state that at the start.. I have all the conection details <?php include('db_connect.php'); ?>

Can u see any other errors Sad
Thanks

The Cyber World

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 5 years 26 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

Can anybody help?

No, can't see anything else blatently wrong.

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.