Notice: Undefined index: id in C:\xampp\htdocs\project1\edit.php on line 4 – PHP

  php

Q(Question):

i get the id value right from the database but in the update statement doesn’t work….

<?php
mysql_connect('localhost','root','');
mysql_select_db('project_1');
$id =$_GET['id'];
$title = $_POST['title'];
$discr = $_POST['discr'];
$location = $_POST['location'];
$date = $_POST['date'];
echo $id;
if(isset($id) && isset($title) && isset($discr) && isset($location) && isset($date)){
echo $id;
$query = "UPDATE `project_1`.`event_manager` SET `event_manager`.`event title`='$title',`event_manager`.`discription`='$discr',`event_manager`.`location`='$location',`event_manager`.`date/time`='$date' WHERE `event_manager`.`id`=`$id`";
if(mysql_query($query)){
echo 'the table s updated';
}
}
?> <form action='http://bytes.com/edit.php' method='POST'>
title:<br/><input type="text" name="title"><br/><br/>
discription:<br/><input type="text" name="discr"><br/><br/>
location:<br/><input type="text" name="location"><br/><br/>
date:<br/><input type="text" name="date"><br/><br/> <input type='submit' value='update' name='update'> </form>

A(Answer):

OK, I get to say it this time 🙂
Just telling us that something doesn’t work is often not enough. Please tell us what is that you expected to happen, what is that is actually happening, and any errors (including the number) that you have received.

With that said….
what is up with all of these single quotes:
`project_1`.`event_manager` in line 12
Honestly I don’t know PHP; thus, I may be off – however, it looks awfully strange to me

A(Answer):

Line 4, why is that the only one using GET when the others are using POST?

A(Answer):

With that said….
what is up with all of these single quotes:
`project_1`.`event_manager` in line 12
Honestly I don’t know PHP; thus, I may be off – however, it looks awfully strange to me

these are not single quotes, these are backticks and they are used to quote a MySQL field/table name (e.g. if the name would otherwise be invalid (containing a space or a registered keyword))

A(Answer):

Dormilich: Thank you for the information. As I stated, I don’t know PHP 🙂 For the same thing in the languages I do code in I’d be using the square braces "[]" It is interesting that PHP would break with that convention.

A(Answer):

that’s not a PHP thing, that is MySQL-style SQL. PHP merely passes the string to the DB but does itself nothing with it.

besides that, I never heard of such a convention. I could as well state that your languages break the convention *gg*

A(Answer):

and to that I’d say MicroSoft
(ROTFL)

LEAVE A COMMENT