mb2000inc's Profile User Rating: -----

Reputation: 21 Tradesman
Group:
Contributors
Active Posts:
338 (0.19 per day)
Joined:
10-November 09
Profile Views:
24,519
Last Active:
User is offline Aug 19 2014 10:04 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Who Cares
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
XBox
Your Car:
Ford
Dream Kudos:
125

Latest Visitors

Icon   mb2000inc is working hard at avoiding actual work.

Posts I've Made

  1. In Topic: Not your usual unidentified index....

    Posted 19 Aug 2014

    That's a beautiful thing.

    I will be revamping my code and posting the new stuff here.

    Thanks to everyone for your advice! It's well appreciated.
  2. In Topic: Not your usual unidentified index....

    Posted 19 Aug 2014

    View PostArtificialSoldier, on 18 August 2014 - 05:12 PM, said:

    So that you don't need to refer to the result as $nextRow['MAX(`UserID`)'], it's common to give that result an alias and then refer to it using the alias.

    SELECT MAX(`UserID`) AS `num` FROM UserTable
    


    Ok, so.... when I call the result like this:
    $UserID = (int) $nextRow['UserID'] + 1;
    


    I would actually call it like this?
    $UserID = (int) $nextRow['num'] + 1;
    


    Please forgive the confusion. Like I said, I'm still new to PHP.

    View PostDormilich, on 19 August 2014 - 03:02 AM, said:

    View Postmb2000inc, on 18 August 2014 - 05:57 PM, said:

    I thought about the "auto increment" but as I'm still learning PHP, I wasn't sure how to pass that into the DB (would that be a NULL value and the DB populate it?).

    the point of an auto increment is that you do not pass anything, otherwise it wouldn’t be auto …


    Ooh, I like that... I think I might have to make some changes...

    So, in my insert statement, I would leave out the 'UserID' field, all together?
    INSERT INTO UserTable (leave out userid and move on to the next field) VALUES (same as before without userid)
    
  3. In Topic: Not your usual unidentified index....

    Posted 18 Aug 2014

    View PostArtificialSoldier, on 18 August 2014 - 01:51 PM, said:

    As for the error, PHP is correct that the array you are referencing does not have an index by that name. Print out the array to see what the indexes are called:

    $nextRow = mysqli_fetch_array($newRez);
    print_r($nextRow);
    


    Just out of curiosity, what's the difference between using "print_r" and "echo"?

    OK, this is what was returned:
    Array ( [0] => 1 [MAX(`UserID`)] => 1 )
    


    Interesting....
  4. In Topic: Not your usual unidentified index....

    Posted 18 Aug 2014

    Good point. Let me give your code a shot and see what I get back.
  5. In Topic: Not your usual unidentified index....

    Posted 18 Aug 2014

    $UserID is set to 0 at the top of the page, and isn't being used until that query pulls it out and makes it + 1.
    I thought about the "auto increment" but as I'm still learning PHP, I wasn't sure how to pass that into the DB (would that be a NULL value and the DB populate it?). I was just fiddling around with the code to see if I can make it work before refining everything... and you are correct - Prepared Statements will be happening.

    As for the Email address thing, I wasn't sure how to go about retrieving that and displaying it on the page if it was kicked out. I will research that later.

My Information

Member Title:
D.I.C Regular
Age:
40 years old
Birthday:
November 17, 1973
Gender:
Location:
Left of Center
Interests:
I love programming and developing on top of writing, video work - and now POD CASTING!
(You can also find me here: http://roosterteeth.com/mb2000inc and here http://www.youtube.com/user/mb2000inc and http://thequarerootofnegativeone.com)
Full Name:
Mark Bogner
Years Programming:
10
Programming Languages:
C#, VB.NET, SQL, HTML/CSS - and now, PHP!

Contact Information

E-mail:
Click here to e-mail me
LinkedIn:
http://www.linkedin.com/pub/mark-bogner/b/745/899
Facebook:
http://www.facebook.com/MarkPBogner
Twitter:
mb2000inc

Comments

Page 1 of 1
  1. Photo

    duffgirl Icon

    10 Jul 2013 - 15:37
    Ohio is wonderful! That must be why folks like us live here.
  2. Photo

    Yo! Icon

    26 Sep 2011 - 15:26
    I live by your status
  3. Photo

    hulla Icon

    14 Sep 2011 - 02:07
    :D
  4. Photo

    hulla Icon

    13 Sep 2011 - 08:30
    Nice status
Page 1 of 1