| | |
Connecting to database
Thread Solved |
•
•
Join Date: May 2008
Posts: 60
Reputation:
Solved Threads: 0
Hey whats up guys? I was using thenewboston tutorials on youtube and I am stuck. I was trying to connect to my database that i made.
Thanks for your help guys.
PHP Syntax (Toggle Plain Text)
<?php //opens connection to mysql server $dbc=mysql_connect('localhost','kybo13','****'); if(!$dbc) { die('Not connected: ' . mysql_error()); } //select database $db_selected=mysql_select_db("kybo13_game",$dbc); if(!$db_selsected) { die("Cant connect: " . mysql_error()); } //test $query="UPDATE game SET email='hopethisworks' WHERE username='kybo13'"; $result=mysql_query($query); ?>
You have to be more explicit. "It still doesn't work" doesn't help much. I ran a modified version of your code as follows and it worked correctly:
You may have a problem with your DB or the names / parms you are using for it.
Chris
PHP Syntax (Toggle Plain Text)
<?php //opens connection to mysql server $dbc=mysql_connect('localhost','root',''); if(!$dbc) { die('Not connected: ' . mysql_error()); } //select database $db_selected = mysql_select_db("test",$dbc); if(!$db_selected) { die("Cant connect: " . mysql_error()); } //test $query="UPDATE test_table SET field1='hopethisworks' WHERE id='00001'"; $result=mysql_query($query); ?>
You may have a problem with your DB or the names / parms you are using for it.
Chris
![]() |
Similar Threads
- connecting database in javascript (JavaScript / DHTML / AJAX)
- ASP.NET: Connecting to database (ASP.NET)
- submiting info into a database for retrieval! (PHP)
- Error connecting to database (ASP.NET)
- struggling with connecting database to server (ASP.NET)
- mySQL database searching for registration (MySQL)
- php wont submit data into the database (PHP)
Other Threads in the PHP Forum
- Previous Thread: How do I install and setup a phpbb forums with phpmyadmin?
- Next Thread: About opensource ?
Views: 560 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
access ajax apache archive array arrays auto box broken buttons cakephp cart check checkbox class classes cms code css curl database date development directory display download dropdown drupal dynamic echo email error file files form forms functions header href htaccess html image include insert integration ip java javascript joomla jquery limit link list login lookup loop mail menu mlm mod_rewrite multiple mysql order output parse password paypal php problem query radio regex remote rows script search select server session sort source sql string structure syntax table tutorial update updates upload url user validate validation variable video web website wordpress xml





