Current location: Hot Scripts Forums » Programming Languages » PHP » phpMyAdmin 2.2.6 & MySQL 4.0.1


phpMyAdmin 2.2.6 & MySQL 4.0.1

Reply
  #1 (permalink)  
Old 10-27-03, 06:02 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
phpMyAdmin 2.2.6 & MySQL 4.0.1

Has anyone used either of these on their own PC? I've downloaded both, plus PHP, onto a WinXP personal PC, and one or the other isn't running properly. phpMyAdmin isn't showing new user permissions when I set them. If I add a new database, add a table and insert info, the dropdown database list won't show all the databases at first, then when it does it'll say that a database (which I just populated) has no tables or info. I'm using these with Apache, not as a server but for my own script writing (learning php/mysql, mostly). PHP seems to be running fine. Any sugggestions what might be going on, or how to fix this? (By the way, this was a program from FoxServ, and I have yet to get a response for help on their support forum).

Thnx
Reply With Quote
  #2 (permalink)  
Old 10-30-03, 11:23 AM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Thumbs up

You have to go into the config file of myphpadmin and specify the username and password you have set for root access to your mysql. There are 2 different places in that config file that you have to specify the username and password for root access in. Once you do that, it should give you permission. I hope this helps.




Quote:
Originally Posted by mdhall
Has anyone used either of these on their own PC? I've downloaded both, plus PHP, onto a WinXP personal PC, and one or the other isn't running properly. phpMyAdmin isn't showing new user permissions when I set them. If I add a new database, add a table and insert info, the dropdown database list won't show all the databases at first, then when it does it'll say that a database (which I just populated) has no tables or info. I'm using these with Apache, not as a server but for my own script writing (learning php/mysql, mostly). PHP seems to be running fine. Any sugggestions what might be going on, or how to fix this? (By the way, this was a program from FoxServ, and I have yet to get a response for help on their support forum).

Thnx
__________________
Reply With Quote
  #3 (permalink)  
Old 10-30-03, 12:15 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
OK, I made some changes. I went to phpMyAdmin 2.5.3, and MySql 4.0.16. phpMyAdmin seems to be fine. If I use phpMyAdmin, I can create db's, tables, and insert info with no problem. If I use a form to add the info and submit to a php script to run an insert query, all that happens is the id field (auto-increment) gets added, but no other fields...and it gets added twice, both entries with successive id numbers. Example..

Add info to a form, the insert result is

id field, name field, city field, state field
1 blank blank blank
2 blank blank blank

Also, in winmysqladmin, it is saying in the ODBC window that Driver 3.51 cannot be found.
I'm also using Apache 2.0.47 and PHP 4.3.3.
Reply With Quote
  #4 (permalink)  
Old 10-30-03, 12:33 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Well, you got the myphpadmin fixed. That's a good first step.
Can you copy and paste the code you are trying to use to insert info into the tables? That way it will be easier to troubleshoot it.
__________________
Reply With Quote
  #5 (permalink)  
Old 10-30-03, 01:27 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Heres the input form...

<form action=insert.php method=post>
Your bands name<br>
<input type=text name="bandname" size=30><br>
Your City<br>
<input type=text name="city" size=30><br>
Your State<br>
<input type=text name="state" size=30><P>
<input type=submit name="Submit" value="Add to the BandBook"><br>
<input type=reset name=reset value="Erase and start over">
</form>

And the insert query....

php
include("dbinfo.inc.php");
$dbh=mysql_connect ("localhost", "$username", "$password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("$database") or die ("Couldn't select database");
$query = "INSERT INTO bandbook VALUES ('','$bandname','$city','$state')";
mysql_query($query) or die(mysql_error());

$result=mysql_query($query);
mysql_close();
/php

"dbinfo.inc.php" is an include for the connection to the db.
Reply With Quote
  #6 (permalink)  
Old 10-30-03, 03:42 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Well, it is definately your syntax. Here is a nice example on how to connect and insert values into a MySQL table. Try running this script and see if it still gives you an error:

Code:
<?php
	$location = "localhost";
	$username = "username";
	$password = "password";
	$database = "database";
	$conn = mysql_connect("$location","$username","$password");

	if (!$conn) die ("Could not connect MySQL");
	mysql_select_db($database,$conn) or die ("Could not open database");

	mysql_query("CREATE TABLE users (
			firstname VARCHAR(20),
			surname VARCHAR(20),
			location VARCHAR(20))");

	$insert = "INSERT INTO users (firstname,surname,location)
	VALUES ('John','Doe','US')";
	mysql_query($insert) or die ("Could not add data to the table");

	$query = "SELECT * FROM users";
	$result = mysql_query($query);
	$numrows = mysql_num_rows($result);

	while($row = mysql_fetch_array($result))
	{
		echo "You have $numrows user(s) in the database";
		echo "First Name: $row[firstname]";
		echo "Surname: $row[surname]";
		echo "Location: $row[location]";
	}

$query = "UPDATE users SET location='SWEDEN' WHERE location='UK'";
$result = mysql_query($query);

	$query = "SELECT * FROM users";
	$result = mysql_query($query);
	
	while($row = mysql_fetch_array($result))
	{
		echo "Location is now: $row[location]";
	}
?>
__________________
Reply With Quote
  #7 (permalink)  
Old 10-30-03, 05:59 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Well, that did work, so I know that info can go into the db from an insert query script. But I still have the problem that the info put into the form is not, for whatever reason, being added to the insert query. This is the main problem, as I want toset this up so I dont have to "hard code" the info into the insert each time I want to add info to the table.
Reply With Quote
  #8 (permalink)  
Old 10-30-03, 07:33 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Use the above example as a template, and build your script on it. You will first need to create a TABLE in your database. For example:

Code:
	$conn = mysql_connect("$location","$username","$password");

	if (!$conn) die ("Could not connect MySQL");
	mysql_select_db($database,$conn) or die ("Could not open database");

	mysql_query("CREATE TABLE bandbook (
			bname VARCHAR(20),
			bcity VARCHAR(20),
			bstate VARCHAR(20))");

	$insert = "INSERT INTO users (bname,bcity,bstate)
	VALUES ('$bandname','$city','$state')";
	mysql_query($insert) or die ("Could not add data to the table");

Quote:
Originally Posted by mdhall
Well, that did work, so I know that info can go into the db from an insert query script. But I still have the problem that the info put into the form is not, for whatever reason, being added to the insert query. This is the main problem, as I want toset this up so I dont have to "hard code" the info into the insert each time I want to add info to the table.
__________________
Reply With Quote
  #9 (permalink)  
Old 10-30-03, 08:44 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
I can already set up the tables and fields thru phpMyAdmin. I finally found the only way I could get the form inputs to pass to the insert query was by using _POST at the beginning of the query.

//php
$bandname=$_POST['bandname'];
$city=$_POST['city'];
$state=$_POST['state'];
$location = "localhost";
$username = "username";
$password = "password";
$database = "bandmatch";
$conn = mysql_connect("$location","$username","$password") ;

if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");

$query = "INSERT INTO bandbook(id,bandname,city,state) VALUES('','$bandname','$city','$state')";

$result=mysql_query($query);
mysql_close();

echo header ("Location: thanks.html");
//php

Don't know why this is the only way the setup will work, possibly something in the configuration of my PHP or mysql. Thnx for the suggestions.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
great product for dumping/recovering MySQL databases Dave Brown General Advertisements 1 10-03-03 07:40 AM
Cannot import into MySQL xgab PHP 1 09-27-03 06:02 PM
mysql to access aspuser25 Database 2 09-16-03 11:01 AM
MySQL with PHP question. HELP for a newbie kenfused PHP 3 08-02-03 12:53 AM


All times are GMT -5. The time now is 07:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.