PDA

View Full Version : MYD's & frm's ?



firebirdfan
12-17-2003, 03:48 AM
Hi I'm new to databases, I can get my program working locally on apache/mysql.
But when I upload to the WH server into a subfolder I cant - I get cant connect to database.
I've installed mysql. I've checked the codes I dont know if the "localhost" connection is the problem - I've checked the filename connection is right.

Pls advise.

wildjokerdesign
12-17-2003, 08:51 AM
Was this request to do with the card script that you got going?

I have phpMyAdmin installed on my sites that use mysql databases so I can check the existance of a database. I have run across a couple scripts that you have to create the database yourself since they do not do it and phpMyAdmin makes it really easy.

firebirdfan
12-17-2003, 06:06 PM
Nope Shawn it;s not related, just wondering why it wouldnt work on the server,when it worked on my localhost.

firebirdfan
12-19-2003, 11:11 PM
Hi guys I would like to know where to place my database folder.

Locally there's a folder in mysql/data/ - where all your databas folders are placed - so that the php pages can connect to it.

I cant find the folder. - Pls help

jalal
12-20-2003, 07:50 AM
Firebirdfan.

I'm not sure if I understood what you are doing (your original question made no sense to me) but now I think that that you are trying to upload the mysql datafiles from your local computer onto your Westhost server (that is, the "myd,myi,frm" files from /var/lib/mysql/).
Is that right?

It won't work. MySQL doesn't work like that.

firebirdfan
12-21-2003, 05:14 PM
Yes, I've uploaded those data files into the same folder of those PHP files that calls out from the data files.

Locally on my desktop with Apache mysql & php installed I can get it working , as I place the data files into the mysql bin folder.

So now on the server I can't find the mysql bin.. therefore my php files cant access the database & hence the error - can pls advise where do i place the data files ?

jalal
12-22-2003, 01:55 AM
It won't work. MySQL doesn't work that way.
You cannot just copy MySQL data files from one computer to another.

I don't have time to go into at the moment (gotta rush out) maybe I'll get back to you later....

wildjokerdesign
12-22-2003, 09:51 AM
When I move database files I use phpMyAdmin between accounts on WestHost. You can "save" and download them on one account and them upload them on the other all via phpMyAdmin. Not sure if that is where jalal was going or not.

You can also upload or add to a database file from a text file on your computer using phpMyAdmin. You might want to see if phpMyAdmin can read the database files on your local computer. I have a feeling it may be able to but not sure. I know I keep harping on phpMyAdmin but it is the only way I have found to work with databases without really diging in and learning all the tecnical stuff behind MySQL. I am learning some but for now it lets me get things up and running in via a browser enviroment.

If I am completely off on what you are doing please just disregard my post. :)

torrin
12-22-2003, 01:29 PM
Yea, I'd think it would work if you go through an interface like phpMyAdmin. I think Jalal is saying you can't copy the actual data file that mysql stores the data in from computer to computer. I haven't tried it, but that's probably true.


I know I keep harping on phpMyAdmin but it is the only way I have found to work with databases without really diging in and learning all the tecnical stuff behind MySQL. I am learning some but for now it lets me get things up and running in via a browser enviroment.

I agree, I tried reading through the manual (http://www.mysql.com/doc/en/index.html) earlier this year. Unless, you're trying the become a database administrator, I don't recommend it.

jalal
12-22-2003, 02:29 PM
Well, just to clarify my rushed statement earlier.
You can, in theory, copy the .myd, .frm etc files from one computer to another, but then you have to find a way to let MySQl know that they are there, what permissions to grant them and so on. Its hard work, and MySQL provides a much easier way.

On your local database, export all the data as a SQL text file, upload the file to your web site, create a database and import the files into the database.
Now, Unix gurus with beards and sandals will just do all this from the command line, using the MySQL client 'mysql', using something like:
$ mysql -u mydomain -p mydatabase < export.sql
(should you be interested)

But as Shawn mentions, there is an even easier method and that is to use PhpMyAdmin to do it.
Export the file from the local computer (go to the database in the menu on the right, there will be a tab on the top of the page named 'export', go there, select the table(s) you want, make sure you have 'SQL' checked, and export it to a text file on your local disk).

Next, go to PhpMyAdmin in your website, create the database that you want to load the data into (or use an existing one).
Go to the tab marked 'SQL' and there should be a text box there called 'Location of text file'. Enter the location of the text file that you just created (use the browse button) and then let PhpMyAdmin upload the file to the server and insert all the data and so on into the database.

Finished!

firebirdfan
12-22-2003, 09:53 PM
I found the mysql folder on the server which is /var/lib/mysql/
When viewing through PHP myadmin I get to select the tables and all, now my problem would be telling the php file to connect to it.

wildjokerdesign
12-22-2003, 10:00 PM
Can you give us more on the php file? You well have to let it know the username and password some how and you should connect using localhost. Does that ring any bells or help? Pluse tell it how the database it is connecting to.

firebirdfan
12-23-2003, 03:22 AM
I really appreciate it guys- thanks so I'll post me code here:
/* Connecting To Database */

$objconnect=mysql_connect ( "localhost", "xtalog" ,"") or die("cannot connect to DB");
mysql_select_db("xtalog",$objconnect) or die("Could not select database");
$ssql="select * from MT_Item where parentid = '0' ";
$rs_query=mysql_query($ssql) or die("Query failed : " . mysql_error());

$rs=mysql_fetch_array($rs_query,MYSQL_BOTH);
?>
<table width="300" align="right" bgcolor="#F0F8FA" border="1" bordercolor="#FFFFFF" >
<tr align="center">
<td colspan="2" ><div align="center">button/main_category.gif</div></td>
</tr>
<? while(!(($rs==0))){ ?>
<tr>
<td width="203" align="left" valign="middle" ><div align="left"><font color="#0066CC" face="Verdana, Arial, Helvetica, sans-serif" size="2"><? echo $rs["itemname"]; ?>
</font>
<? echo $rs["itemdesc"]; ?>
</div>

<div align="right"> </div>
</td>
<td width="116" height="20" align="right" valign="top"> <p class="text">
<a href="bed11.php?id=<?php print $rs{'ID'};?>"> button/btn_open.gif</a>
</td>
</tr>
<tr>
<td class="tablebg" height="20" colspan="3" >&</td>
</tr>
<tr>
<td colspan="2" align="right" >
<? $rs=mysql_fetch_array($rs_query);

if (($rs==0))


{

?>
</td>
</tr>
</table>
</div>
<?
/* print "<tr><td>&</td><td>&</td></tr>";*/
$rs=mysql_fetch_array($rs_query);

}


else
{

?>

<? }

}
?>





<div id="Layer2" style="position:absolute; left:686px; top:316px; width:98px; height:23px; z-index:10"><a href="http://www.abc.com/abc.htm">occ2_files/RUBbed_39.jpg</a></div>
<div id="Layer3" style="position:absolute; left:155px; top:69px; width:308px; height:308px; z-index:11; overflow: scroll;">
<!-- ########################### end bar Box #############################-->
<table width="200">
<tr>
<td>
<?php /* Set Page Size and Other variables here*/

/*

$PageSize = 10;
$StartRow = 0;

//Set the page no
if(empty($_GET['PageNo'])){
if($StartRow == 0){
$PageNo = $StartRow + 1;
}
}else{
$PageNo = $_GET['PageNo'];
$StartRow = ($PageNo - 1) * $PageSize;
}

//Set the counter start
if($PageNo % $PageSize == 0){
$CounterStart = $PageNo - ($PageSize - 1);
}else{
$CounterStart = $PageNo - ($PageNo % $PageSize) + 1;
}

//Counter End
$CounterEnd = $CounterStart + ($PageSize - 1);

//page Size End here
*/




$objconnect=mysql_connect ( "localhost", "xtalog" ,"") or die("cannot connect to DB");
mysql_select_db("xtalog",$objconnect) or die("Could not select database");
$id=$HTTP_GET_VARS["id"];
$ssql="select * from mt_item where parentid='".$id."'";
//print $ssql;
$rs_query=mysql_query($ssql) or die("Query failed : " . mysql_error());
$rs=mysql_fetch_array($rs_query,MYSQL_BOTH);

if (($rs==0))
{
print "<a>&&</a>";
print "No Record Found";

}
else
{

}


while(!($rs==0))
{
//$bil = $i + ($PageNo-1)*$PageSize;
//print "
".$bil;
if ($rs{'type'}=="folder")

Browsing through PHPmyadmin I can see all the tables etc.
Not knowing mysql & phpmyadmin, no time to study either- i'm in a fix.

I wonder what could be the problem... the programmer that did this ought to get shot- he left for holiday.

It's just a snippet of the code, & I hope that you all could help me.
Practically that's how every php page has it at the top.

thanks

wildjokerdesign
12-23-2003, 09:33 AM
Ok you are not going to like my answer to this one. I really hope you did not pay this person for this code. In my opinion it is a big mess. Here is a little bit on it.

$objconnect=mysql_connect ( "localhost", "xtalog" ,"") or die("cannot connect to DB");
This should contain three arguments the hostname, the database username and the database password. I see you have localhost that is correct. If xtalog is not the database username that should be changed. The last you have empty but should contain the password for the database.

Your existing top code and what it should be doing:

mysql_select_db("xtalog",$objconnect) or die("Could not select database");
This should contain two arguments the datbase name and the link identifier for the connection. It looks to be correct if xtalog is the database you are connecting to.

$ssql="select * from MT_Item where parentid = '0' "; This is a total mess. Right now it is saying Select all for lack of a better term from MT_Item which I hope is a table in your database and where parentid = '0' which should be a row in the table MT_Item.

$rs_query=mysql_query($ssql) or die("Query failed : " . mysql_error());
This is just getting the query.

$rs=mysql_fetch_array($rs_query,MYSQL_BOTH);This sets a single accocieative array form the the set result. The $rs_query is correct have no idea where the MYSQL_BOTH is from.

?>
Ends the php

Ok I would start by cleaning some things up and doing some testing to see what may not be working try this. I do not see the tag to open the php at the top of the page so that is the first thing you well see in mine.


<?php

$objconnect=mysql_connect ( "localhost", "username" ,"password");
if ( !$objconnect ){
ehco "Can not connect to DB";
}
else {
ehco "Connected to DB";
}

mysql_select_db("xtalog",$objconnect) or die("Could not select database");

$ssql="SELECT *
FROM MT_Item
WHERE parentid = '0'";

$rs=mysql_fetch_array($rs_query);

?>

I think that should be correct and get you connected to the database and make the initial query. With the rest of the page I would suggest going through it and placing some of it on seperate lines so it is easier to see and find mistakes. I would but both the <?php and the ?> on seprate lines form the rest of the stuff to make sure they are all there. I well not that he has used <? instead of <?php which I do not think matters but is a personal prefrence on my part.

For me the code is so tight and untidy that it is really hard to follow what he was trying to do or if there is any mistakes in it. Give the above a try first and in fact maybe even put it in a php document by it self to see if you are connecting to the database.

Wish I could be more help.

firebirdfan
12-23-2003, 08:20 PM
With regards to paying that -person --- it's ur guess.

So I should replace username & password with the real password & username that I've created ? So ppl viewing my code will know my password ?

Wow wee it sure works, - I'm able to connect to the database now, when I view source, I cant see the username & password though - so how does php work ?- it's ok i'll read it later.

well now I'm sort of playing with it - & I wonder in Linux - all things are case sentitive right - as I comb through the codes I realize that sometimes the filename liek MT_Item is name in small caps, it work fine in windows
but when I uploaded it to the server it got errors so i named it appropriately to file name & it worked - can I imply that the person who developed the code also worked on a windows system ?

Thanks all, esp Shawn.

wildjokerdesign
12-23-2003, 09:58 PM
With regards to paying that -person --- it's ur guess.

Ummm... oops!

Yes it well have to have the username and password for the database you created. Of at least that is how I have seen it with most php scripts. I did see mention that they could be left blank and it would use the username and password of the person logged in but I do not think that apply here. You can set up a config.php file for the pages that has the database, username, password ect in it and then call it in each page using include()

I did notice something else. In php you should use echo to print something out and not print. I think I noticed that in part of the code.


if (($rs==0))
{
print "<a>&&</a>";
print "No Record Found";

}
else
{

}

Do you by any chance have the phpBB board set up on any of your accounts? It is a good example of setting up config and function files that are called by each script. I have only been playing with php for about two months and looking through that code and others has really helped.

It looks like you have connected twice in the same page to the database which I do not think you have to. Also I don't see where the script closes the connection.

I mentioned this before but if you can go through and put some space between things like the php from the html. This well help you see if there is any html mixed in with the php which would mess things up.

I assume you are getting a blank page with this right?

I'll try and take another look at it tommarow and see what else I can see.

firebirdfan
12-23-2003, 10:23 PM
I cant thank you enough Shawn, I'm not getting a blank page. Upon copying your psoted codes - the item ids wasnt pulling - as you removed some codes - namely $rs_query=mysql_query($ssql) or die("Query failed : " . mysql_error());

Now I'm able to connect & view it as well, yes this programmer sure is a messy person.
Well it's christmas & we ought to be forgiving :)
I've got phpdev installed on me winxp system. it's from firepages.com.au - it comprises of apache/mysql/perl & php. - all in one - :)
Within phpdev there's the invision board & I'm constantly posting ot myself my daily journals -& mistakes that i make...real nice havent got time to study the things further until i settle this issue of the catalog here. it's fun - i didnt know it was that fun -- thanks all.
so now i dont have to use phpmyadmin to create databases - yippie

firebirdfan
12-24-2003, 04:03 AM
Shawn thanks also for you suggestions i will definitely take that into consideration - but after testing out many times - i think my connection exceeded - so i get this error - Query failed : Can't lock file (errno: 116)

while trying it on another domain it works okay..any insight

also would like to know why cant i enable the Tcp/ip connection box for mysql while my other to domains can - i've checked & i do allow remote connection.

wildjokerdesign
12-24-2003, 08:59 AM
I did a search and found some info the first is this page I want to post a link to since I have been looking for something like it for awhile. It is a list of errors and kind of what they mean http://www.knowd.co.jp/staff/nils/mysql-error-codes.html

From what I can tell it is an erro that MySQL server is sending out. Since it works on other accounts I would try and figure out what is different between them like if the others are a Static IP and this one not. Are there Site Apps on the other accounts that are not on this one.

On a Dev Shed forum I found another user having this problem http://forums.devshed.com/t19585/s.html and they finnaly concluded that it did not have to do with his php but that something was wrong with his mysql and that he should contact his mysql administrator. So if you can't see an obvious difference in the accounts you may need to contact WestHost and have them check your mysql.

That is about all I could find on it.

firebirdfan
12-25-2003, 07:45 PM
Looking at the suggested link - errno 116 states Stale NFS file handle

I think it's time to submit a ticket support .