0

I tried the below coding (PHP with HTML) to develop the website. It is working well with the localhost environment .For web hosting i had purchased space in Godaddy. I tried this code in localhost with Ampps server and it shows the content in the table format. I successfully uploaded the content in Godaddy. But did not get the table in live accessing.

Coding

mysql_connect("localhost", "root", "mysql")or die("cannot connect"); 
mysql_select_db("ex")or die("cannot select DB");
# Prepare the SELECT Query
$selectSQL = 'SELECT * FROM `volume1` where no=1';
# Execute the SELECT Query
if( !( $selectRes = mysql_query( $selectSQL ) ) )
{
echo 'Retrieval of data from Database Failed - #'.mysql_errno().': '.mysql_error();
}
else
{
?>
<table border=1 border color=#e5e5e5 width=925>
<thead>
<tr>
<td style="font-size: 21px; font-weight: bold; color: #ffffff;" width="479" bgcolor="#ffffff" align="center"><span style="color: #000000; text-decoration: none;">Title/Author Name</span></td>
<td style="font-size: 21px; font-weight: bold; color: #ffffff;" width="29" bgcolor="#ffffff" align="center"><span style="color: #000000; text-decoration: none;">Pdf</span></td>
</tr>
</thead>
<tbody>
<?php
if( mysql_num_rows( $selectRes )==0 )
{
echo '<tr><td colspan="4">No Rows Returned</td></tr>';
}
else
{
while( $row = mysql_fetch_assoc( $selectRes ) )
{
?>
<tr><td> <font align="justify">
<?php
echo "<font size=4 color=#0a0953>{$row['title']} </font> <br><font size=3 color=#07666e><br> {$row['author']}</font></td><td>\n";
?></font>
<a href="images/pdf/<?php echo"{$row['pdf']}";?>.pdf" target="_blank">
<img src ="images/pdf.jpg" height="40" width="40" />  
</a>
</tr>
<?php 
}
}
?>
Porkodi
  • 9
  • 1
  • I don't think the correct MySQL credential on GoDaddy is `root` with empty password. Did you create any database and MySQL user in the GoDaddy control panel at all? – Koala Yeung Sep 17 '19 at 06:02
  • If there is no problem in the database connection then try to look at your table name and fields name because it might be case sensitive. – N. Alcuino Sep 17 '19 at 06:12
  • Possible duplicate of [Why shouldn't I use mysql\_\* functions in PHP?](https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Dharman Sep 17 '19 at 08:58

2 Answers2

0

The problem is probably on these lines:

mysql_connect("localhost", "root", "mysql")or die("cannot connect"); 
mysql_select_db("ex")or die("cannot select DB");

You can't see the table since there's no data in it.

You will have to find/create an account for the GoDaddy database (also put some data there) and then change the mysql name, password and database accordingly.

EDIT: Also mysql_* functions are deprecated, use mysqli_* instead if possible.

0

Please create a Database in your GoDaddy's control panel -> MySQL Databases and create a database there and move your local database here.

Also, check your PHP Version in your cPanel and change if needed.

Sanjun Dev
  • 518
  • 8
  • 20