Page 1 of 2
Re: php edit data page issue
Posted: Tue Jun 30, 2015 8:51 am
by Celauran
You're setting $visitor_id to a string literal. That can't possibly be right. Should be, well, an ID, no?
Re: php edit data page issue
Posted: Tue Jun 30, 2015 9:36 am
by Celauran
The content of that column is going to be a number, isn't it? You're passing a string value, 'visitor_id', into the query. That should probably be replaced with a value from the user's session or something.
Re: php edit data page issue
Posted: Tue Jun 30, 2015 10:18 am
by Celauran
That's the right idea, yes.
Re: php edit data page issue
Posted: Tue Jun 30, 2015 10:47 am
by Celauran
Can you post the code in question? Sounds like $_SESSION['user_id'] might not be set, which leaves $visitor_id with a null value.
Re: php edit data page issue
Posted: Tue Jun 30, 2015 10:57 am
by Celauran
You're selecting it, so you should be getting it back. Have you checked that $visitor_id is being set? Have you examined what you're getting back from the database?
Re: php edit data page issue
Posted: Tue Jun 30, 2015 11:07 am
by Celauran
ianhaney wrote:is def weird, how can I check to see if the visitor id is being set
Code: Select all
$visitor_id = $_SESSION['user_id'];
var_dump($visitor_id); exit;
You really want some sort of checking that $_SESSION['user_id'] is set before doing anything that depends on it.
Re: php edit data page issue
Posted: Tue Jun 30, 2015 11:08 am
by Celauran
var_dump your rows, too, to see what's coming back from the DB
Re: php edit data page issue
Posted: Tue Jun 30, 2015 11:34 am
by Celauran
If you don't have visitor_id available via the session, then you're not going to be able to pass it into the query and will need to use what you have. Joining on the users table could work. I don't recall users having a visitor_id foreign key, though. How are the tables related?
Re: php edit data page issue
Posted: Tue Jun 30, 2015 11:55 am
by Celauran
ianhaney wrote:I think the site getting confused, in the users table is a record of 14 when the user(me) signed up and when I went to the second form, it's storing the data from the second form with a visitor_id record of 75
Why?
No, seriously. Why is it designed this way? What is the benefit of this design? Are visitors entirely distinct from users? Could the information not be combined into a single table?
ianhaney wrote:so I think I need the user_id of 14 to correspond with the visitor_id of 75 within the database tables
Yes, you'd need to establish a foreign key relation, so your users table would have a visitor_id column to connect the two. Before proceeding to do that, however, consider my questions above.
Re: php edit data page issue
Posted: Tue Jun 30, 2015 1:00 pm
by Celauran
Where are you inserting records into the users table?
Re: php edit data page issue
Posted: Tue Jun 30, 2015 1:07 pm
by Celauran
Where. You've got the query defined, but I don't see it being executed anywhere.
Re: php edit data page issue
Posted: Tue Jun 30, 2015 1:18 pm
by Celauran
No it's not. You're defining $sql, not executing the query, then overwriting $sql with new values.
Re: php edit data page issue
Posted: Tue Jun 30, 2015 1:22 pm
by Celauran
Re: php edit data page issue
Posted: Tue Jun 30, 2015 1:23 pm
by Celauran
$id is undefined because you're asking for the insert ID of a query that was never run
Re: php edit data page issue
Posted: Tue Jun 30, 2015 1:37 pm
by Celauran
ianhaney wrote:Notice: Undefined variable: error in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/register.php on line 79
Where have you defined $error?
ianhaney wrote:Warning: Cannot modify header information - headers already sent by (output started at /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/register.php:80) in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/functions.php on line 11
I feel like we've discussed this. You cannot send headers after having sent output to the browser. Leave your markup at the bottom of the file. Logic comes first so you can do things like redirect or set headers or whatever.