Jump to content

Recommended Posts

Posted

I am atempting to build a small database using php and MySql. When I try to connect, I do not get any MySql errors but I am not able to read any of the data I have built into the small database with the phpadmin tools on the server.

 

Does anyone have any suggestions?

 

Nativeg

Posted

Hi Nativeg

 

:) :dance: Welcome to the family :dance: :dance:

 

I'm not sure without a little more information.

 

Are the initial connections correct?

 

 

Name of host - localhost

Database Name - cpanelusername_dbname

Datbase User Name - cpanelusername_dbusername

 

I assume so as you are not getting any errors.

 

You say you can not read any data. Do you get an error message? or the wrong data? or just blank data?

Posted

The Host, Username and Database name all seem to be correct.

 

After I go through the connect procedure to the database

This is my code:

 

All I want to do at this time is to query the db so I can read the files I have already added using the tools TCM provides

 

Here is my query code:

I first define the DB_HOST, DB_USER,, DB_PASSWORD, and the DB_NAME.

 

Then my code continues as:

 

$dbh=mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die ('I cannot connect to the database because: ' . mysql_error());

@mysql_select_db (DB_NAME) or die ('I cannot connect to the database because: ' . mysql_error());

 

echo "Database is (DB_NAME) and has connected properly: <p>";

 

$query ="SELECT * FROM dbase22 LIMIT 0, 30" ;

$result = mysql_query($query ) or die ('I cannot read the database because: ' . mysql_error());

 

echo "$result <br>" ;

echo " . . . were the results of this show query <br><br><br>";

echo " <br><br> $query ";

 

echo '<table align="center" cellspacing="2" cellpadding="2"> <tr> <td align="left"><b>CALLSIGN</b></td><td align="left"><b>NAME</b></td><td align="left"><b>EMAIL</b> </td> </tr>';

 

// Fetch the records.

 

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {

echo" <tr><td align = \"left\">

$row[0]</td><td align = \"left\">

$row[1]</td> <td align = \"left\">

$row[2]</td></tr> \n";

}

 

echo '</table>';

mysql_free_result($result);

 

}else{

echo'<p> no info due to a system error</p> <p>'. mysql_error().'</p>';

}

mysql_close();

 

Ok So where did I go wrong?

Posted

It might help to turn error reporting up. By default, it is set very low at TCH.

 

Try putting this at the start of your script

 

>error_reporting(E_ALL);

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...