![]() |
|
|
#1 |
![]() Join Date: Nov 2008
Location: Birmingham, England...
Posts: 472 (0.29/day)
Thanks: 72
Thanked 27 Times in 22 Posts
|
phpMyAdmin and mySQL Connection
Hi All
I have a mySQL DB and have edited it using phpMyAdmin and woul dnow like to access it on my website... Is this the right connection code? Code:
$connection = mysql_connect('localhost', 'admin', 'password') or exit('Could not connect (' . mysql_errno() . '): ' . mysql_error());
Thanks
__________________
![]() |
|
|
|
|
|
#2 |
|
Benevolent Dictator
Join Date: May 2004
Location: Stuttgart, Germany
Posts: 13,764 (4.18/day)
Thanks: 184
Thanked 10,209 Times in 3,157 Posts
|
it's easiest if you create a php function like
PHP Code:
|
|
|
|
| The Following User Says Thank You to W1zzard For This Useful Post: |
|
|
#3 |
![]() Join Date: Nov 2008
Location: Birmingham, England...
Posts: 472 (0.29/day)
Thanks: 72
Thanked 27 Times in 22 Posts
|
Thanks wizzard... Do I need to setup $dbname in a variable outside the function?
__________________
![]() |
|
|
|
|
|
#4 |
|
"I go fast!1!11!1!"
Join Date: Oct 2008
Location: IA, USA
Posts: 10,574 (6.29/day)
Thanks: 1,752
Thanked 2,596 Times in 1,960 Posts
|
No, you could just make a connect() function with everything defined inside. The way he set it up allows him to use the same function to access many databases.
__________________
Golden Rule of Programming: Never assume. try { SteamDownload(); } catch (Steamception ex) { RageQuit(); } |
|
|
|
| The Following User Says Thank You to FordGT90Concept For This Useful Post: |
|
|
#5 |
![]() Join Date: Nov 2008
Location: Birmingham, England...
Posts: 472 (0.29/day)
Thanks: 72
Thanked 27 Times in 22 Posts
|
Thank you
![]() May have more questions later!
__________________
![]() |
|
|
|
|
|
#6 |
![]() Join Date: Jan 2012
Location: Dover, New Hampshire, USA
Posts: 4,242 (8.86/day)
Thanks: 1,265
Thanked 1,322 Times in 981 Posts
|
adodb makes a good DB abstraction layer.
http://adodb.sourceforge.net/ PHP Code:
PHP Code:
__________________
MyHeat Last edited by Aquinus; Apr 10, 2012 at 12:03 PM. |
|
|
|
| The Following 3 Users Say Thank You to Aquinus For This Useful Post: |
|
|
#7 |
![]() Join Date: May 2009
Location: In the mountains :) Adirondacks in NY (US)
Posts: 3,705 (2.54/day)
Thanks: 4,534
Thanked 1,442 Times in 1,038 Posts
|
i like that aquinus, will be using it shortly
__________________
Donate to TPU TeamSpeak Server ![]() TPU TS: ts21.gameservers.com:9207 PSN / XBL / Steam = digibucc | Origin / BF3 = digibuc |
|
|
|
| The Following User Says Thank You to digibucc For This Useful Post: |
|
|
#8 |
![]() Join Date: Nov 2008
Location: Birmingham, England...
Posts: 472 (0.29/day)
Thanks: 72
Thanked 27 Times in 22 Posts
|
Thanks Digi
__________________
![]() |
|
|
|
|
|
#9 |
![]() Join Date: Jan 2012
Location: Dover, New Hampshire, USA
Posts: 4,242 (8.86/day)
Thanks: 1,265
Thanked 1,322 Times in 981 Posts
|
I might add that phpMyAdmin isn't exactly the most secure web service. I wouldn't host it where anyone can get a hold of it. I'm assuming you're working locally on your own machine or in a virtual machine with no access to your web server externally.
__________________
MyHeat |
|
|
|
|
|
#10 |
![]() Join Date: Nov 2008
Location: Birmingham, England...
Posts: 472 (0.29/day)
Thanks: 72
Thanked 27 Times in 22 Posts
|
It's nothing important... The only wasy I know how to test is save it from dreamweaver, upload it using filezilla, then navigate to the url!
In the end, I went for this code... Can anyone tell me (using the same SIMPLE ways i'm using) where and how I would get the password submitted from part1.html and compare it to the username? Thanks PHP Code:
__________________
![]() Last edited by Tatty_One; Apr 18, 2012 at 12:16 PM. Reason: Triple post madness! Keep it tidy |
|
|
|
|
|
#11 |
![]() Join Date: Jan 2012
Location: Dover, New Hampshire, USA
Posts: 4,242 (8.86/day)
Thanks: 1,265
Thanked 1,322 Times in 981 Posts
|
A: There is an edit button, use it instead of posting multiple times.
B: What does the Users table look like? C: You would add it to the SQL query. D: Why in the world are you using Dreamweaver? If you want to write a web application the right way, I would get virtualbox and install a basic Ubuntu Server with a LAMP stack and edit everything using VIM. This would help with configuration if you're not familiar with debian based servers. https://help.ubuntu.com/community/ApacheMySQLPHP What is your knowledge level as far as PHP and SQL is concerned? I'm assuming you're new to both because of the comment next to the query saying to remember to put a space before the where. Personally, when I have to put SQL into a variable, I do it like this. PHP Code:
__________________
MyHeat |
|
|
|
|
|
#12 | |
![]() Join Date: Aug 2007
Location: Geneva, FL, USA
Posts: 3,010 (1.43/day)
Thanks: 567
Thanked 606 Times in 487 Posts
|
Quote:
|
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wired LAN connection and USB wireless connection? | squelchy451 | Networking & Security | 18 | Feb 3, 2012 03:31 PM |
| Unidentified wireless network connection on laptop(local only connection) | Rado D | Networking & Security | 5 | Jun 2, 2011 11:22 AM |
| Setting up WordPress using phpMyAdmin on 1and1 | ChiSox | Programming & Webmastering | 3 | Feb 24, 2010 05:16 AM |
| some html php and mysql mixed question | r9 | Programming & Webmastering | 2 | Aug 30, 2009 04:24 PM |
| help needed with phpmyadmin | r9 | Linux / BSD / Mac OS X | 9 | Mar 14, 2009 06:33 PM |