Author Topic: PMA mysql inserts are working but inline PHP are not...  (Read 1115 times)

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
PMA mysql inserts are working but inline PHP are not...
« on: September 08, 2010, 01:23:46 PM »
For reasons unknown to me i can insert just fine into my table from within phpmyadmin but within pure PHP it's not working what so ever. The query is below and it refuses to work within PHP itself.
Code: [Select]
    $conn = mysql_connect($dbhost,$dbuser,$dbpass)
or die ('Error connecting to mysql');
    mysql_select_db($dbname);
that is done beforehand so that i don't have to make sure that i don't have any problems with database selection part of it.
Code: [Select]
$sql = "INSERT INTO item(name,main_type,rarity,stack_size,sub_type,cost,ilvl,flavor_text,rlvl,final) VALUES ('test1',0,5,0,0,0,255,'test1',0,1);";and in php it's just put within mysql_query() and it doesn't do it's insert. It just i don't know it doesn't work. the id row is of course on auto-increment so it works just fine within pma but in php no query happens. It's as if there's some unheard of constraint within itself. But the only foreign key constraints i have are on other tables and link back to the item id. I'd understand if it wouldn't work within PMA and also native PHP but it seems as though it's just refusing to run. I have mysqli set to be used on both of them.

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: PMA mysql inserts are working but inline PHP are not...
« Reply #1 on: September 08, 2010, 02:18:02 PM »
Have you tried checking the result of the query? Is the result a boolean false value? If so, have you tried calling mysqli_error() (or $mysqli->error() depending upon your usage) to get the message from the database?

In most cases, the database error will tell you if you're doing something wrong.
Idiocy - Never underestimate the power of stupid people in large groups.


Offline Winawer

  • Level 6
  • *
  • Posts: 27
  • Reputation: +0/-0
    • View Profile
Re: PMA mysql inserts are working but inline PHP are not...
« Reply #2 on: September 08, 2010, 02:27:49 PM »
Try removing the semicolon.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: PMA mysql inserts are working but inline PHP are not...
« Reply #3 on: September 08, 2010, 02:54:33 PM »
Space after tablename and escaping on `final` maybe?

Of course you could choose the easy route and try mysql_error(); but where would be the fun of guessing then :D

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
Re: PMA mysql inserts are working but inline PHP are not...
« Reply #4 on: September 08, 2010, 06:37:46 PM »
i don't know why i didn't think to use mysql_error() before now. It seems as though the real query i was trying to do i forgot out a comma so thus it wasn't inserting properly.

also for some reason trying to use mysqli() doesn't seem to want to run. Admittedly, i just did a search and replace case sensitve mysql_ to mysqli_ and then MYSQL_ to MYSQLI_

and i'm procedural all of the way i refuse to use classes and objects they're silly things and nothing more to me.

Offline Nox

  • Level 35
  • **
  • Posts: 768
  • Reputation: +12/-2
    • View Profile
Re: PMA mysql inserts are working but inline PHP are not...
« Reply #5 on: September 09, 2010, 03:04:03 AM »
mysql and mysqli DOES NOT differ in case sensitivity like stripos => they're completely different libraries (MYSQLI = MYSQL+Improved)

Quote
and i'm procedural all of the way i refuse to use classes and objects they're silly things and nothing more to me.
been there before, that will likely change ;)
« Last Edit: September 09, 2010, 06:11:59 AM by Nox »
Meet us at an IRC irc.freenode.net #bbg as well
https://vimeo.com/36579366 (a must-watch) | Join BOINC - no longer a hype, but you can help never the less

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: PMA mysql inserts are working but inline PHP are not...
« Reply #6 on: September 09, 2010, 08:56:33 AM »
and i'm procedural all of the way i refuse to use classes and objects they're silly things and nothing more to me.
In pure C (100% procedural) you still have "struct" which is basicly a class but without methods, constructor and deconstructor. And, while I fully agree that procedural is much more efficient for solo game development, the knowledge how it works bring some benefits even if you don't use it.

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
Re: PMA mysql inserts are working but inline PHP are not...
« Reply #7 on: September 09, 2010, 05:51:01 PM »
mysql and mysqli DOES NOT differ in case sensitivity like stripos => they're completely different libraries (MYSQLI = MYSQL+Improved)

Quote
and I'm procedural all of the way i refuse to use classes and objects they're silly things and nothing more to me.
been there before, that will likely change ;)

and i know that they're completely different. I was trying to start using it instead of mysql's base library. I looked it up for a few and saw that all i had to do was put an i after it so i went with it for all.

On the topic of OO vs Procedural. I've programmed in both, I've wrote programs in both. And OO is slow inefficient and doesn't feel natural. I've thus far had my hand at Z80 Assembly, BASIC, C#,Java, and Python before i decided on the OO vs Procedural. All of my programming classes i took i was pretty much forced to use OO they were all preaching about how much easier it was and how much faster it was for development. Yeah sure it was amazing to see it starting off but that new feeling kind of wore off extremely fast. It didn't feel natural and then the realization that it's slower than procedural was the kicker.

I'm using INNODB for everything since it's faster for multiple queries plus the foreign keys and i'm also using mariaDB with the innodb optimized version of the innodb library for the speed usage. Also for speed i probably should have been using something like python but php had a lesser barrier into entry as far as the web services went.

If/when i get additional people to work with me I'll make sure that they too all code in procedural and will fire them on the spot if they dare put any OO code into my code base. OO has it's places for those who don't care about performance for the "ease of supposed use" the same way that NOSQL is still going to be around for a very long time but RDBMS systems shall always be around and with people like google releasing patches that improve upon it's speed then it's going to be even better for it's use. Both NOSQL and OO are fads to me, made by people who don't like the odd ways of the older generations and believing that they can improve upon it by going in a completely different way. the OO development was kind of faster when doing prototyping but when it comes to hard coding it's just no replacement for procedural. If i wanted to be more about learning all of the various aspects of game development on the programming side i'd probably write my own custom server but for now i'm doing it for the design experience. In the future i hope to get back into assembly programming so i can truly feel the speed and efficiency.

Offline Barrikor

  • Level 21
  • *
  • Posts: 248
  • Reputation: +3/-0
    • View Profile
Re: PMA mysql inserts are working but inline PHP are not...
« Reply #8 on: September 10, 2010, 01:27:21 AM »
In defense of OO, it's no fad. Folks sometimes misuse OO in terrible ways, and often use it unnecessarily; however it does have its uses. Many things that need to get coded make far more sense as objects.

In essence, OO is just one method (out of many) for attaching vars and functions together. By its fundamental design, OO will need more memory allocated then other paradigms, but any notable loss of speed when using OO ultimately means that someone did not write the code effectively somewhere down your language's toolchain.

However, I must agree with you on not using Mysqli's OO, all the OO fetch functions are far slower than their procedural equivalents.
« Last Edit: September 10, 2010, 01:36:19 AM by Barrikor »
Projects: Pith Framework (at 0.5), CactusGUI (at 0.3)

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal