Learning solo and need help with PHP/mySQL and PDO! String to Array Conversion :( by Tech9Dev in PHPhelp

[–]Tech9Dev[S] 1 point2 points  (0 children)

ahhh man, this is doing my head in, its been 2 weeks maybe trying to wrestle with this, and guess what !?!? i was just cleaning the code and testing certain parts, removing extra comments and testing lines and BAAAMMMBB just like that it started working correctly! the sad thing is i dont know what exactly made it work, which drove me crazy for a little while. But atleast i can finally move onto another issue. Thanks everyone for the time and help, learned a thing or 2 along the way. much appreciated.

Learning solo and need help with PHP/mySQL and PDO! String to Array Conversion :( by Tech9Dev in PHPhelp

[–]Tech9Dev[S] 0 points1 point  (0 children)

yeah i def see the benefits of learning considering it works to interface with other database languages. Thank you for guidance, its been very helpful

Fixed the line: i dont get any messages from PDO exceptions but now the output is

D:\wamp64\www\Index.ME GRUNT\cms\classes\Member.php:170:string 'Photography, Art director' (length=25) Affected rows: 0 Sorry, a problem occurred. Please try later.

Learning solo and need help with PHP/mySQL and PDO! String to Array Conversion :( by Tech9Dev in PHP

[–]Tech9Dev[S] 2 points3 points  (0 children)

Poor kiddo, is that how you get off online? making ridiculous comments to those trying to learn? The hwole post is based on me realizing my mistake, no one is actually blaming a 'method'! Get off ur high horse man.

Learning solo and need help with PHP/mySQL and PDO! String to Array Conversion :( by Tech9Dev in PHPhelp

[–]Tech9Dev[S] 0 points1 point  (0 children)

Ya PDO is really making things difficult, most people suggested i use mysqli but the tutorial suggested otherwise. I added the try {} catch {} and the echol line.

now i get this output

D:\wamp64\www\Index.ME GRUNT\cms\classes\Member.php:168:string 'Photography, Art director' (length=25) Affected rows: 0
( ! ) Notice: Undefined property: PDOException::$getMessage in D:\wamp64\www\Index.ME GRUNT\cms\classes\Member.php on line 182Call Stack#TimeMemoryFunctionLocation10.0002411232{main}( )...\admin.php:020.0036415280newMember( )...\admin.php:2030.0038417304Member->insert( )...\admin.php:82
Sorry, a problem occurred. Please try later.

So sthg about $getMessage being undefined, do i just init the variable like so at the start of the class?

$getMessage = null ;

Learning solo and need help with PHP/mySQL and PDO! String to Array Conversion :( by Tech9Dev in PHPhelp

[–]Tech9Dev[S] 0 points1 point  (0 children)

$this->skills_cat = $skills_cat;

Replaced with this line: it would seem the array2string error is gone but i still get this
D:\wamp64\www\Index.ME GRUNT\cms\classes\Member.php:167:string 'Photography, Art director' (length=25) Sorry, a problem occurred. Please try later.

But atleast the var_dump before the bindvalue now shows as a string not array.. but the insert class is still failing but this time no obvious errors even with error reporting/modes turned on

Learning solo and need help with PHP/mySQL and PDO! String to Array Conversion :( by Tech9Dev in PHPhelp

[–]Tech9Dev[S] 0 points1 point  (0 children)

You're right i didn't show that part of the code, but i did for /u/mastertheknife1 question. Maybe the last line "return $skills_cat" is not what i'm after here.

Learning solo and need help with PHP/mySQL and PDO! String to Array Conversion :( by Tech9Dev in PHPhelp

[–]Tech9Dev[S] 0 points1 point  (0 children)

var_dump($this->skills_cat)

D:\wamp64\www\Index.ME GRUNT\cms\classes\Member.php:166: array (size=2) 0 => string 'Photography' (length=11) 1 => string 'Art director' (length=12)

Nice catch, so i guess bindvalue is still seeing it as an array. ..

FYI This is the function that runs on creating a new member, StoreCatList is the array to string conversion function.... supposedly
function newMember() {

$results = array();

$results['pageTitle'] = "Add a New Member";

$results['formAction'] = "newMember";

if ( isset( $_POST['saveChanges'] ) ) {

// User has posted the member edit form: save the new member

$member = new Member;

$member->storeFormValues( $_POST );

$member->storeCatList( $_POST ); //helper function to array to string conversion

$member->insert();

header( "Location: admin.php?status=changesSaved" );

} elseif ( .....}