Help - Search - Members - Calendar
Full Version: Database Issues
Zymic Webmaster Forums > Zymic Free Web Hosting > Databases & MySQL
The Seventh Hokage
and determined that it isn't the code. it's the database.. or specifically a problem accessing the database.

it's a very simple code to insert a row into a table in my database.

it worked the first time i used it....
and nevermore.

i dissected the code and made sure EVERY part of it worked (i spent the last two weeks doing that) before i posted here.

is there some kind of quirk with the databases on zymic that restrict SQL database changes to occur from the webpage?

if so i can understand the security issue.

but the database loads so SLOW. it's much easier to update it from a webpage. i have the form set up and everything.

any help help on this situation would be appreciated. No code included.. becuz all the code works sleep.gif
NaRzY
Please post your code. I am sure we can assist you in connecting.
The Seventh Hokage
QUOTE(NaRzY @ Oct 9 2009, 10:23 AM) *
Please post your code. I am sure we can assist you in connecting.

i don't think the code is the problem.
The Seventh Hokage
hunter.gif
the code
CODE
<?php
session_start();//to make use of session vars on an earlier page.
include "connection.txt";

$elemType=$_SESSION[scrtype];

echo $elemType;//a check to make sure the sessions vars are set and working. and they do.


//this switch case sets the variables dependent on the value.
switch($elemType)
{
case "Non":
$nonelem=1;
$fielem=0;
$wielem=0;
$waelem=0;
$earelem=0;
break;

case "Fire":
$nonelem=0;
$fielem=1;
$wielem=0;
$waelem=0;
$earelem=0;
break;

case "Wind":
$nonelem=0;
$fielem=0;
$wielem=1;
$waelem=0;
$earelem=0;
break;

case "Water":
$nonelem=0;
$fielem=0;
$wielem=0;
$waelem=1;
$earelem=0;
break;

case "Earth":
$nonelem=0;
$fielem=0;
$wielem=0;
$waelem=0;
$earelem=1;
break;

}

/* simple insert query using the session values and the vars defined earlier with the switch statement*/

$ssq= "INSERT INTO `scrolls` (`name`,`effect`,`non`,`fire`,`wind`,`water`,`earth`,`description`,`quantity`) VALUES ('$_SESSION[scrname]','$_SESSION[scrvalue]','$nonelem','$fielem','$wielem','$waelem','$earelem','$_SESSION[scrdesc]',1)";

$ssres= mysqli_query($cxn,$ssq) or die (mysql_error());// connect code.

?>

relevant info:
I used it yesterday and it worked fine on my website. But only once. every other attempt to use this code has failed.

other pages on my site are suffering from the same problem. they all use the same connection to connect.

never one time have i used a close connection command. thats the only thing i can think of that may cause the problem.

the segment of code has been looked at by another zymic member earlier last week.
swordz
Where are the actual connection lines?

You're still using some messy syntax as well - interpolated variables take longer, also it doesn't like the [,] characters I find without {} around the variable. Then, your keys are actually constants. Have you defined these constants? I doubt it. You should be escaping them to be strings.

Can you please put var_dump($_SESSION); before the $ssq line, then run this page and paste the ENTIRE output. Also, can you not use include - it means we don't actually see the whole script. Also, including a txt file is risky - if someone finds out where it is, it'll be served as a text file, giving people your passwords.

Swordz
The Seventh Hokage
QUOTE(swordz @ Oct 9 2009, 09:03 PM) *
Where are the actual connection lines?

You're still using some messy syntax as well - interpolated variables take longer, also it doesn't like the [,] characters I find without {} around the variable. Then, your keys are actually constants. Have you defined these constants? I doubt it. You should be escaping them to be strings.

Can you please put var_dump($_SESSION); before the $ssq line, then run this page and paste the ENTIRE output. Also, can you not use include - it means we don't actually see the whole script. Also, including a txt file is risky - if someone finds out where it is, it'll be served as a text file, giving people your passwords.

Swordz

1) everyone has different coding styles. unless you can point me to a "proper" tutorial. im just going to have to learn as i go. And if your going to teach me to do it the right way.. please explain the terminology smile.gif

granted some of it might be a little off. but i am working on a pretty big project by myself.

2) Because as i've been saying since the beginning of this post ALL my other connections work FINE.
And i did them the same exact way as this one.. actually i left some of the stuff you told me OUT and they still work completely fine. and have been for almost 4 months now. If the syntax was the cause.. wouldn't it be safe to assume that it would have manifested months ago when i first used it?

3)i chose to work from big to small. the website is not open to the public or even close to beta testing YET becuz i can't even insert into a database.
I stripped and escaped all my data, i tinkered and tested on my own for weeks before i even posted here. Me having to wait on replies slows down my work. i would rather work it out myself.. it's just that through trial and elimination i've realized it could possibly be the settings zymic has set up for php my admin.. which is what i asked and no one answered about. all i was told is to "post code"

I just had a simple question. Sure the code needs to be touched up. But my issue here is why isn't the database accepting a query that worked 2 minutes beforehand?
it only happens when i try to UPDATE or INSERT. aka.. change info in the database or add to DB from the webpage.



4)and i know about the text file. i'm going to change all that and fix all security issues before i get ready to beta test. And by the same token, that's why my connection information is IN a include file....security.

having said all that i will post the dump info u requested


oh and thanks for noticing the constants. i was in such a rush to get the code working that i didn't notice!
The Seventh Hokage
CODE
Nonarray(7) { ["logged"]=> string(3) "yes" ["charname"]=> string(8) "Loveless" ["charclan"]=> string(13) "Hidden Shadow" ["scrname"]=> string(16) "Thousand Daggers" ["scrtype"]=> string(3) "Non" ["scrvalue"]=> string(5) "10000" ["scrdesc"]=> string(21) "1000 Daggers fly out." }
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.