PDA

View Full Version : PHP wont work


MJS
06-10-2007, 09:43 PM
Hi David could tell me why this code will not work.


<?php
session_start();
require_once("Connections/connection.php"); // database connection
include('Includes/security.php');
//////////////////////////////////
$id = $_SESSION['id'].""; /// person logged on shows on to this page this works OK
///////////////////////
$available = $_POST['available'];
$events = $_POST['event_id'];
$wat1 = $_POST['wat1'];
$submit = $_POST['submit'];
///////////////////////
$query = sprintf("Select * FROM events where event_id = $events and events = wat1");
$result = @mysql_query($query);
$rowUpdate = @mysql_fetch_array($result);
//////////////////////
$Yes = 1;
$No = 2;
$Maybe = 3;
switch($available){
case '1' : $event = "Yes"; break;
case '2' : $event = "No"; break;
case '3' : $event = "Maybe"; break;
}
$query = sprintf("update events set wat1 = $events where events = $id");
@mysql_query($query) or die (mysql_error());
////////////////////////////
?>

davidj
06-10-2007, 09:51 PM
this is incorrect...

("Select * FROM events where event_id = $events and events = wat1");


you need single quotes around the first var and the second var needs to be written as a var like this...

("Select * FROM events where event_id = '$events' and events = '$wat1'");

davidj
06-10-2007, 09:54 PM
You are getting very confused i think

your switch uses a variable called $event but your update statement uses $events ????

is this right???



switch($available){
case '1' : $event = "Yes"; break;
case '2' : $event = "No"; break;
case '3' : $event = "Maybe"; break;
}

davidj
06-10-2007, 09:59 PM
if your having too much trouble with this project we could start a seperate thread and take this one step at a time

MJS
06-11-2007, 02:06 PM
Thanks David I have updated the $event to $events the brain was not working to well I have had best part of a week away from the computer putting in a new bath room must keep the good woman sweet and think it could be a good idea to start a new thread I seem to have got into a bit of a fix with this.

davidj
06-12-2007, 01:10 PM
ok mate

start a new thread with the heading...

please help me oh Magnificent one...

and we shall make a start with this project