« first day (594 days earlier)      last day (4353 days later) » 

6:07 AM
Hey all I have a problem with my php code..
I have a form.. where the user types in details.. for my forn.. event name, event date and location
basically the bit that is working
is
well first of all i would like to add an entry into 2 tables: events and results
it's having no problems adding the entry into events
but it doesnt add the same entry into "results"
the events table had the following columns: Event ID, Event Name, Event Date and Location
The Results table has: Event ID, Member ID, Event Name, Score and Place
The Event ID is auto increment
so it auto assigns an ID to it
and its applied to both tables
the auto increment in Event ID
the bit thats working is
inserting entry into the events table
but because the events table and results table both have "Event Name
I want this php to fully insert details for the event table
BUT also at the same time, just insert the eventname into the results table
 
Sam
are the 2 tables somewhat related?
 
Erm
Well it has a few columns with the same name
erm Event ID in events is linked to Event ID in events
But Event ID is set as auto increment so it generates an ID by itself
 
6:24 AM
is result table uses any column that is not in your form?
 
Sam
do the data in both tables have a connection, a sort of dependency relationship?
 
or just print the query in your code and paste it into the sql editor in phpmyadmin, then you will get the exact mysql error related with the second table
 
yes
in this form
i am fully inserting data into events
so
event name date and location
because ID generates by itself
but for results i am only adding in event name and leaving the others blank
 
then for results table>
 
but the ID in results somehow have to match the ID in events
for that entry
eg. if the entry i just did generated an ID=11 in events, somehow the results table entry must also have ID=11
 
6:27 AM
check the structure of the results table and make sure that the 'not null' is not enabled for the corresponding field
 
Sam
if it's auto-incremented, the id will be the next integer after the biggest integer in the column
 
yeah
lets say
the events tab
is currently generated up to
 
Sam
so, both numbers might not be the same
 
ID=11
but results is only up to ID=6
oh right then ill just have to delete all the entries and restart them again to make them er even
 
Sam
if you delete a data in one table, does it delete the same row in the other table?
 
6:30 AM
no
i have to delete them both one at a time
 
Sam
your db schema might be a little off; based on your explanation above, the Event table should be a parent table, and the Result table a child of the Event table
so, the event id in the Result table will be a foreign key, matching to the proper row in the Event table
with such a relationship, deleting the row in the Event table will automatically delete the subsequent row(s) in the Result table (if the tables use InnoDB)
 
erm i'm not allowed to touch any of the set schema coz it was already set up for us..
but actually i think i might give it a try
give me 1 minute
yeah.. it doesnt..
 
Sam
what doesn't?
 
erm well ive deleted eventID2 in events
but the eventID2 in results
is still there
 
hi
is someone using php based OSTicket system
 
Sam
6:39 AM
that is one of the problems you'll face with a schema like that;
 
yeah
 
Sam
you have to manually delete the data from every dang table in the db
 
yeah thats fair enough
lol
 
vvr
hi all
 
Sam
so, suffice to say that your data will have integrity issues
 
6:39 AM
i just need it to insert the the eventsname from events table
into eventsname in results table
 
Sam
hi vvr
hi techno
 
Hey vvr
 
vvr
 
Sam
to insert in the tables, just insert them the usual way
 
hi sam
 
vvr
6:40 AM
suggest me best way to aproach it
 
Sam
if you want them to have the same number
 
is someone using php based OSTicket system
 
Sam
specifically insert the number you want them to have
 
sorry about the massive code post
$pdo = new PDO('mysql:host=localhost;dbname=clubresults', 'root', '12345678');
#Set Error Mode to ERRMODE_EXCEPTION.
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt=$pdo->prepare('INSERT INTO events (EventName, EventDate, Location)
VALUES (:EventName, :EventDate, :Location)');


$stmt->bindValue(':EventName', $_POST['EventName']);
$stmt->bindValue(':EventDate', $_POST['EventDate']);
$stmt->bindValue(':Location', $_POST['Location']);

$stmt->execute();



?>
<?

$stmt = $pdo->prepare('
 
im not able to fetch mails automatically
 
6:41 AM
is that correct?
 
Sam
at least, that way, you can control
them
yeah...looks correct
 
im getting the "EventName cannot be null
 
Sam
the datatypes of those values will be string by default
 
its weird coz the eventname
when i press submit
it adds the entry into events
 
Sam
that means that the $_POST['EventName'] has no value in it
 
6:43 AM
just not results
is it because
 
Sam
that code inserts the data into the Events table only
 
its gone through the first php
and deleted itself
and leave no value for the 2nd php
hm.. what can i do to make it insert the same name into 2 tables..
 
Sam
you can insert the same data in any amount of tables
especially if they have no relationship
as long as the column type allows it
 
well they have the same name
the columns
in events
and results have the same column name
Event Name
 
Sam
it doesn't matter; they are still diff tables
 
6:46 AM
oh
lol i think i need to fix that not null issue first before i can get on
 
Sam
and although the columns have the same name, it's irrelevant
 
vvr
is any one seen my code?
 
erm sorry vvr im a complete noob in php
 
Sam
if you can, fix your db schema too
 
i cant lol the teacher made it for us and it says in the specifications we are not allowed to alter anything
 
Sam
6:47 AM
otherwise, you'll have headache later with data integrity
 
except for adding a few columns more
 
Sam
really? a teacher made that db schema?
 
uni
 
vvr
@billChen not a problem
 
LOL
 
Sam
6:48 AM
what engines do the tables use? MyISAM?
 
no idea
im using XAMPP
if that helps
and i think its running on innodb
 
Sam
ok.....to solve your immediate problem
you can store the data in variables first, and echo them to ensure that the variables exist
 
yeah
 
Sam
once you confirm that the data exist, you can then insert them into the tables
 
hm
its weird why is the buttons in the coding not in yellow writing!
 
Sam
6:50 AM
and ensure that the columns which do not access null must be filled
 
yeah
 
Sam
what buttons?
 
<input type='button' value='Retry' onClick='history.go(-1)'>
those buttons theyre not in yellow writing in dreamweaver
 
Sam
@vvr have you used that code?
to Bill: is that related to PHP?
 
i have no idea
but usually when its its inside <form> and </form>
it turns different colour
 
Sam
6:56 AM
that's not a PHP issue that you can be helped here; you might need to check out Dreamweaver forums
 
yeah nah its just my computer its fine
dam why is it still showing eventname not null
im testing the phps one by 1
hm
the eventdate and location arnt showing up the not null issue
only eventname...
this is the form area
<div class="required_field">
<label for="EventName">Event Name</label>
<input name="EventName" id="EventName" type="text">
<span id="EventNameerror" class="error"></span>
</div>
<?

$pdo = new PDO('mysql:host=localhost;dbname=clubresults', 'root', '12345678');
#Set Error Mode to ERRMODE_EXCEPTION.
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt=$pdo->prepare('INSERT INTO events (EventName, EventDate, Location)
VALUES (:EventName, :EventDate, :Location)');


$stmt->bindValue(':EventName', $_POST['EventName']);
$stmt->bindValue(':EventDate', $_POST['EventDate']);
$stmt->bindValue(':Location', $_POST['Location']);

$stmt->execute();
?>
 
Sam
what columns are in the Events table?
don't paste code here
use pastie.org or pastebin.com
 
oh okay sorry
 
Sam
and send us the link here
 
EventID (auto icrremented)
EventName
EventDate
Location
 
Sam
7:01 AM
ok....do you have PHPMyAdmin open?
 
yeah
im currently in the events table in phpmyadmin
 
Sam
ok....echo the eventname, eventdate, and location on the screen
and using the data, insert them directly using PHPMyAdmin
 
Sups
 
Sam
hi Anfurny
 
sorry could u elaborate a little bit in echo the eventname, eventdate, and location on the screen
 
Sam
7:03 AM
the data are retrieved from a form, right?
 
i type the data into a php form
press submit and it adds that entry into phpmyadmin
well mysql db
Hey there AnFurny
 
Sam
the first thing you want to verify is that when the form post, you retrieved the data properly
 
okay.. so how do i do that
 
Sam
so, try something like this: var_dump($_POST);
 
where do i erm copy paste run this?
Main Account Registration
* All Fields Mandatory



Event Name

Event Date


Location Select Game Room Game Room 1 Game Room 2 Game Room 3


array(5) { ["EventName"]=> string(8) "asasasas" ["EventDate"]=> string(10) "2012/02/02" ["Location"]=> string(11) "Game Room 1" ["gameroom"]=> string(0) "" ["submitbutton"]=> string(6) "Submit" }
oh dam sorry i forgot to put in pastebin
 
Sam
7:06 AM
put that code at any block of code that's supposed to run after the form is submitted
oh ok...good
 
btw this is only adding into the events table now coz im testing it
 
Sam
so, to check that the data is right, paste something like this in the PHPMyAdmin
insert into Events values(null, 'sasasas', '2012/02/02', 'Game Room 1')
 
oh by the way this echo is er both adding into events and results: array(5) { ["EventName"]=> string(9) "gfdgdfgdf" ["EventDate"]=> string(10) "2000/02/02" ["Location"]=> string(11) "Game Room 2" ["gameroom"]=> string(0) "" ["submitbutton"]=> string(6) "Submit" } array(5) { ["EventName"]=> string(9) "gfdgdfgdf" ["EventDate"]=> string(10) "2000/02/02" ["Location"]=> string(11) "Game Room 2" ["gameroom"]=> string(0) "" ["submitbutton"]=> string(6) "Submit" }
 
Sam
if those datatypes are valid, that should run fine through PhPMyAdmin
 
okay
1 row inserted
it works
 
Sam
7:10 AM
ok
 
with ur code u just provided
 
Sam
what columns are in the Results table?
 
EventID, MemberID, EventName, Score, Place
 
Sam
are any of the columns nullable?
 
can i choose whether i want it to be null or not u mean?
 
Sam
7:12 AM
well, it was decided when the table was created
 
in results
i cant chahge eventid member id score and place
but i can change eventname
BUT
from wat i see.. only score and place is NULL
I created the column eventname so i can change it anyway i like
 
Sam
ok....that $_POST array you posted didn't contain a score, member_id and place
 
yeah thats correct
 
Sam
so, what values do you have for the memberid and eventname?
 
whats wrong in the below code because its post only once instead of 3

foreach ($groups_list_array["data"] as $value) {
try
{
// compile the post for for user
$WallPost = array(
'access_token' => $current_atoken,
'message' => 'messaeg',
'picture' => 'http://example.com/3_381308561906199_1148597331_n.jpg',
'caption' => 'caption',
'description' => 'description',
'link' => 'https://www.facebook.com/pages/some-text/218575500');

//echo 'value id:' . $value["id"];
// post to user wall
$response = $facebook->api('/' . $value["id"] . '/feed','POST',$WallPost);
 
7:16 AM
well i want to add the details into events table but just add eventname into results
because ive created a separate php file to edit the results table which works perfectly
 
Sam
well, the table schema tells you that you must provide a value for the memberid and eventname anytime you want to add data to the Results table
 
and because thats how its stated in the assignment specs
oh..
 
Sam
so, without those 2, it's impossible to add data into the table
 
ah
 
@Sam please also check my code
 
7:18 AM
well ive already got eventname
 
Sam
unless you can change them into nullable
 
so its just the memberID
 
Sam
yup
 
erm can i ask u a stupid question?
 
vvr
@sam i i used that code
 
Sam
7:18 AM
@AbdullahAdam how do you know it should run 3 times?
lol....ask the question
 
how complicated is it to erm view the list of MemberID's in a combobox in a php form
 
Sam
if it's stupid, ppl will point it out to you
there's no combobox in PHP/HTML
 
@Sam i use for each loop and get groups list caring 3 groups id
 
dropdown box?
drop down list
 
Sam
you can either have a dropdown that selects 1 item, or a dropdown that selects multiple items
 
7:20 AM
erm just 1 item
actually wait a second
in my members table
ive got MemberID, FirstName, Lastname, TeamName
is it possible to show the teamname in the dropdown list
 
Sam
@AbdullahAdam try something like var_dump(count($groups_list_array["data"]));
 
rather than the memberID?
show the teamname list based on the memberID
 
Sam
@AbdullahAdam that lets you know how many elements your array has
 
ello mates,
 
Hey there Nick
 
Sam
7:22 AM
@Nick King of the Nite
:)
@BillChen you can show whatever you want
 
@Sam idk bout that you're certainly a competitor
 
@Sam its show 3
 
Sam
as long as you retrieve the right data from the database
 
but then lets say erm will the teamname be based on MemberID
eg. MemberID = 1 Teamname = gg.net
 
Sam
@Nick how are you, buddy?
 
7:23 AM
if i choose gg.net will it link to MemberID=1?
or is gg.net just gg.net
 
@Sam not bad just finishing up some work, deciding how long I should stay up for, you?
 
Sam
@AbdullahAdam ok....it should run 3 times then; is that all the code?
@BillChen it will show either, depending on how you set it up
:D
 
ooh
erm well ill get searching on google then :P
 
Sam
@Nick nice......I'm just relaxing; probably drifting off soon
 
Yeah same at this point
 
7:25 AM
@Sam ya this the complete code of foreach
 
Sam
@BillChen but usually, how dropdown are built is simple: retrieve the id and name of the data from the db; assign the id as the value of the option, and the name as the text
 
do i need a like
 
Sam
@Nick sweet....:)
 
a hidden text box
 
Sam
nope
 
7:27 AM
oh?
 
Sam
not for that
@AbdullahAdam paste the entire code on pastebin.com, and send the link here
we'll look at it, and see if you've missed something
 
Sam
@BillChen why do you need a hidden textbox?
 
oh coz i did a combobox before and well when i select the value
nothing gets added
 
Have you seen Project X yet?
 
7:28 AM
CB to TV
 
Sam
@Nick what's ggg? lol
 
lol
CB to TB
 
Sam
@Nick what's that?
@BillChen you are mixing many things up;
 
yes.
 
@Sam lol not a redditor, its Good Guy Greg
 
Sam
when you submit a form that contains a dropdown, the value (not the text) in the selected option will be sent to the server
and you can use it for w/e you want
@Nick lol....how about Good Guy Sam ?:P
 
PDO GetColumnMeta()
is that the one to use to fetch column values?
 
@Sam Because then it'd be GGS
 
Sam
lol....GGS sounds......hmmm....I'm not sure how it sounds
not very cool though
@BillChen you mean fetch data from the db using PDO?
 
yeah
well fetch column data
 
7:33 AM
@sam link pastebin.com/sn36NAT0
 
What's it like in Texas? Is everyone republic ?
 
Sam
@AbdullahAdam I can't see anything in there that'll prevent the code from running 3 times, unless there was an error
it's hot in TX; cost of living is low, compared to other places
 
@sam i didn't get any error
 
Sam
it's a red state; mostly republicans; believed to comprise of ppl with lower IQ
 
but there is some problem in foreach loop
 
Sam
7:36 AM
one of the energy HQ of the nation; etc
 
that doesnt seem right..
 
Sam
@AbdullahAdam what's the output supposed to be?
 
@Sam its posted on one group instead of 3
 
@Sam I've never been, I've been to Arizona a few times, California, Florida never Texas :/
 
Sam
@BillChen that's not right; @Nick; do you have link to that PDO tutorial teresko usually displays on here? Seems like @BillChen will benefit from it
 
7:39 AM
yes please
 
Shit I know which one you're talking about but I don't think I have it handy
 
Sam
lol.....well, ppl don't usually come to TX to relax :)
I have the link on my desktop, which seems about a mile from my current position :)
@AbdullahAdam which part of the code does the actual posting to groups?
 
@Sam my script is now working :)
 
Sam
@AbdullahAdam ahh....that's great :D
 
something like "facebook=>api)" from my above code
:)
 
Sam
7:44 AM
@AbdullahAdam so, it's working perfectly?
 
yes :)
 
Sam
sweet :)
there you go
dozing already, @Nick
?
 
ooh
thanksss
 
Sam
you are welcome
 
@Sam Nope just finishing off some work, deciding what I want to watch before I go to bed
 
Sam
7:53 AM
picked up my Android book this week
 
Are you learning java?
 
Sam
took a JAVA class last semester
so, better start using the knowledge for something good, right? :)
 
@Sam haha yeah, what else are you going to use it for ;)
 
Sam
lol....something evil? :P
but yeah.....start working on Android platform :)
 
7:59 AM
Do you know what you're building yet?
 
Sam
nope.....just learning first
 
i think im getting a bit closer
 

« first day (594 days earlier)      last day (4353 days later) »