Jump to content

If - else problem with database connectivity


miligraf

Recommended Posts

Hey there, the problem ive encountered is:

 

I made a control panel but i run a two language site, so instead of having two different files for each language, ived used this in every file (add, edit, delete) so they have a language selector with an URL like this www.domain.com/?page=add&connection=english:

 

$connection=$_GET['connection'];
include('databaseconnection-selector.php');

 

In the databaseconnection-selector.php file i have this:

 

$connection=$_GET['connection'];
if ($connection==english)
include('english-databaseconnection.php');
else
include('theotherlanguage-databaseconnection.php');

 

Oh and the problem is that i can only Add and Edit for the language that is in the else condition (default) so i have to put the other language in the else condition so i can Add and Edit for that language.

 

I hope you get the idea of what i have done lol :D

Link to comment
Share on other sites

Two things:

 

1. You do not need to have "$connection=$_GET['connection'];" in both files. You are just resetting the variable to the same value

 

2. I believe the problem is due to the fact that you are not enclosing "english" within quotes of your if statement.

 

This

if ($connection==english)

 

Should be this

if ($connection=="english")

Link to comment
Share on other sites

None is working.

 

This is what happens when i try to edit the "english" database (theotherlangua database is in the else so its the default), i get the fields with the info that i can edit and submit changes but when i want to see the changes, i dont see any...it doesnt change the info in the database.

 

Like if i could Add info but not Edit it.

Link to comment
Share on other sites

Ok, its fixed...the form was all in a file so when i hitted "Update" it ran the second part of it but now it runs another file that does the updating ::) BUT i still wonder why this doesnt work (have all in one file)? why do you need another file that does the update part?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.