Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2006-09-18, 06:21 AM
Junior Member
 
Join Date: Sep 2006
Posts: 6
atomek is on a distinguished road
Default access database?

I am a newbie to this:

To begin with, I set up an 'apache' testing server on my machine.
Then using MySQL Front I created a MySQL database from a .xls file to be hosted @ localhost
Using php script through dreamweaver was able to display through a browser, information accessed from within the MySQL database created.

Everything working afters hours of trials and tribulations......

Contacted my isp where I received information regarding access to phpMyAdmin hosted on their server...
Using phpMyAdmin I have imported the data to a table within a database created by my isp.

Table is called 'chemical' database is called 'wx110245' password '******' host 'localhost'

Updated php script to reflect this, and uploaded php file to server via ftp.

though php script is not displaying data.

script is as follows below

world is displayed but no data from the database.....

Q: once I have setup the database in phpMyAdmin is there a last process required in terms of deployment? or is there something else you can see in my process that requires change?
__________________________________________________ _____
<?php print 'world'?>
<?php
$mysqli = new mysqli('localhost','atomek','******');
$mysqli->select_db('wx110245');

$result = $mysqli->query("SELECT* FROM chemical");

while($row = $result->fetch_assoc()) {
print '<hr align="center" width="600">'.'<span class="text01"><b>Chemical: </b></span>'.'<span class="text03"><b>'.$row['Chemical'].'</b></span>'.'<br/>'.'<span class="text01"><b>Paints & Products: </b></span>'.'<span class="text03">'.$row['Paints & Products'].'</span>'.'<br/>'.'<span class="text01"><b>Resins, Varnishes and Stains: </b></span>'.'<span class="text03">'.$row['Resins, Varnishes and Stains'].'</span>'.'<br/>'.'<span class="text01"><b>Caulking/ Fillers/ Sealants etc: </b></span>'.'<span class="text03">'.$row['Caulking/ Fillers/ Sealants etc'].'</span>'.'<br/>'.'<span class="text01"><b>Glues/ Adhesives: </b></span>'.'<span class="text03">'.$row['Glues/ Adhesives'].'</span>'.'<br/>'.'<span class="text01"><b>Walls, Wall frames, Ceilings, Roofing: </b></span>'.'<span class="text03">'.$row['Walls, Wall frames, Ceilings, Roofing'].'</span>'.'<br/>'.'<span class="text01"><b>Timbers: </b></span>'.'<span class="text03">'.$row['Timbers'].'</span>'.'<br/>'.'<span class="text01"><b>Floors and Floor Coverings: </b></span>'.'<span class="text03">'.$row['Floors and Floor Coverings'].'</span>'.'<br/>'.'<span class="text01"><b>Insulation, membranes: </b></span>'.'<span class="text03">'.$row['Insulation, membranes'].'</span>'.'<br/>'.'<span class="text01"><b>Conduits, piping, plumbing: </b></span>'.'<span class="text03">'.$row['Conduits, piping, plumbing'].'</span>'.'<br/>'.'<span class="text01"><b>Fixtures and furnishings: </b></span>'.'<span class="text03">'.$row['Fixtures and furnishings'].'</span>'.'<br/>'.'<span class="text01"><b>Soft Furnishings: </b></span>'.'<span class="text03">'.$row['Soft Furnishings'].'</span>'.'<br/>'.'<span class="text01"><b>Description: </b></span>'.'<span class="text03">'.$row['Description'].'</span>'.'<br/>'.'<span class="text01"><b>Main component use: </b></span>'.'<span class="text03">'.$row['Main component use'].'</span>'.'<br/>'.'<span class="text01"><b>Health concerns and other details: </b></span>'.'<span class="text03">'.$row['Health concerns and other detail'].'</span>'.'<br/>'.'<span class="text01"><b>Sources - see information sources for details: </b></span>'.'<span class="text03">'.$row['Sources - see information sources for details'].'</span>'.'<br/>'.'<br/>';}


$result->close(); ?>
__________________________________________________ _____
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2006-09-18, 11:53 AM
Senior Member
 
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
vladimir_cz is on a distinguished road
Send a message via ICQ to vladimir_cz Send a message via MSN to vladimir_cz Send a message via Yahoo to vladimir_cz Send a message via Skype™ to vladimir_cz
Default

Hi!
1st: turn on maximal error logging: error_reporing(E_ALL)
2nd: after each call of mysql* function check result value. if value is false, output errors like this:
PHP Code:
<?php
$mysqli 
= new mysqli("localhost""my_user""my_password""world");

/* check connection */ 
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}


if (!
$mysqli->query("some query")) {
        
printf("Error: %s\n"$mysqli->error);
    }


?>
__________________
Thank you. Vladimir, Czech Republic.
http://www.smartwebco.com/
I'm looking for job.
Reply With Quote
  #3 (permalink)  
Old 2006-09-19, 03:25 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

Also, fix your print world....

<?ph print("world"); ?>

You forgot the semi colon.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #4 (permalink)  
Old 2006-09-19, 03:35 AM
Junior Member
 
Join Date: Sep 2006
Posts: 6
atomek is on a distinguished road
Default

Thanks vladimir for your reply,

I deleted all existing php script and entered the below, but still no response,

?????1st: turn on maximal error logging: error_reporing(E_ALL)?????? i do not understand this, could you explain a bit more, thanks
__________________________________________________ __________
<?php
$mysqli
= new mysqli("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}


if (!
$mysqli->query("some query")) {
printf("Error: %s\n", $mysqli->error);
}


?>

__________________________________________________ ____________

thank you for all your help.....
Reply With Quote
  #5 (permalink)  
Old 2006-09-19, 04:27 AM
Junior Member
 
Join Date: Sep 2006
Posts: 6
atomek is on a distinguished road
Default

ok... i have come a little further with my issue, i am now using the following code below

page displays:
world
Fatal error: Cannot instantiate non-existent class: mysqli in /var/www/wh223306x001/html/chemiframe.php on line 26

i understand also now that the script to login may be only applicable to a newer version of php and that my isp server my be running an older version

any help on script required for login to older version would be appreciated, otherwise i will keep researching and keep you posted.
_____________________________________
<?php print ("world");

ini_set("display_errors","1");

$mysqli = new mysqli("localhost", "my_user_name", "my_password");
$mysqli->select_db('wh223306x001');

$result = $mysqli->query("SELECT* FROM chemical");


$result->close(); ?>

Last edited by atomek; 2006-09-19 at 04:30 AM.
Reply With Quote
  #6 (permalink)  
Old 2006-09-19, 05:40 AM
Junior Member
 
Join Date: Sep 2006
Posts: 6
atomek is on a distinguished road
Default

Ok, my latest

Thank you all for your help..... special shoutouts go to vladimir_cz & Xnuiem & Alan from my ISP tech support

The following script works for me & displays complete database
(replace my_* as required)

__________________________________________________ _
<?php

ini_set("display_errors","1");

// Connecting, selecting database
$link = mysql_connect('localhost', 'my_username', 'my_password')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');

// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);
?>
__________________________________________________ _____
http://au2.php.net/mysql
Reply With Quote
  #7 (permalink)  
Old 2006-09-19, 10:25 AM
Senior Member
 
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
vladimir_cz is on a distinguished road
Send a message via ICQ to vladimir_cz Send a message via MSN to vladimir_cz Send a message via Yahoo to vladimir_cz Send a message via Skype™ to vladimir_cz
Default

my congratilations!

2forum moderators:
May be to FAQ next sentence:
Quote:
Before create topic/post reply make sure errors displayed and error reporting level set maximal level (E_ALL)
__________________
Thank you. Vladimir, Czech Republic.
http://www.smartwebco.com/
I'm looking for job.
Reply With Quote
  #8 (permalink)  
Old 2006-09-19, 10:44 AM
Junior Member
 
Join Date: Sep 2006
Posts: 6
atomek is on a distinguished road
Default

cheers' vladimir,

Peace out to the 'php-editors crew'
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:26 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.