qim

Member
Mar 26, 2013
9
0
1
cPanel Access Level
Root Administrator
I am new to this and have some simple code to test the database, but nothing happens, I am unsure of the name of my database created through phpMyAdmin. On the left there is a Select window with options. When I open it says _agents whici sthe end of my JustHost ID. Bit below the window there is a square which appears to represent text that is calle Agents with capital "C". I am wondering if my database is called ID_agents/Agents or just ID_agents.

When I scroll the Select window to another databse that I created to test calledID_users, a message comes up saying "No tables found in database". So, I gather that ID_agents is the database and ID_agents/Agents is the full path to the table "Agents".

If that is so, when I try to access the table through the server (public_html) what should I include: the full path ot just the database, whcih is what I suppose they are asking for.

Can you help, please?

Thank you
 
Last edited:

Jeff Shotnik

Well-Known Member
Oct 10, 2012
61
0
6
Denver, Colorado, United States
cPanel Access Level
DataCenter Provider
USERNAME_agents is the database name. What coding language are you using when attempting to access the database? Instead of accessing the database via the file path, your code will likely access the database over port 3306.
 

qim

Member
Mar 26, 2013
9
0
1
cPanel Access Level
Root Administrator
Thanks. I have now managed to get some simple code that confirms access to the database. What I need now is to add a few lines to transfer entered data in a couple of fields into the table.

Can you help?

This is what I have so far, and I have an html form (registration) which I am using to test:

<?php

$db_name = "pintotou_agents";
$open = mysql_connect("localhost", "pintotou_camilo", "*******");
if($open)
echo "1. Successfully connected to MySQL";


echo "</br>";
$db = mysql_select_db($db_name, $open);
if($db)
echo "2. Successfully selected {$db_name} database";


echo "</br>";
$sql = "SHOW TABLES FROM `{$db_name}`";
$result = mysql_query($sql);
$print = mysql_num_rows($result);
if($result)
echo "3. {$print} tables found in {$db_name}";
?>
 

qim

Member
Mar 26, 2013
9
0
1
cPanel Access Level
Root Administrator
You should use prepared statements to help prevent SQL injection,
Hi Jeff

Thanks, I'm stuck before I satrt...

I have a table in a database at the server called 'user' it has two records with 'user' and 'password'

I thought I could asses the data with:

<?php



# connect to the database
{
$DBH = new PD("mysql:host=localhost;dbname=pintotou_agents", "pintotou_camilo", "******");


$DBH->prepare('SELECT password FROM user');
}



?>
But it does not work. I guess I need to specify which record adn echo the result. can you help, please?

Thank you
 
Last edited: