Issues with PHP/MySQL operations

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
maxfavela
Forum Newbie
Posts: 4
Joined: Tue Mar 28, 2006 11:25 am

Issues with PHP/MySQL operations

Post by maxfavela »

I'm not exactly sure, if I need a MySQL connector.
I am new to this. But from what I can understand from
documentation, it seems as if it is not necessary to install
a MySQL Ruby Connector, etc.

PHP Installation Path: C:\PHP
Apache2 Installation Path: C:\Apache2\
MySQL Installation Path: C:\MySQL\

I am running WindowsXP Pro.

Apache Version: 2.0.55
PHP Version: 5.1.2
MySQL: 5.0.19

PHPInfo provides me information, which makes me believe
that my installation of PHP is fine, aswell as activation of
PHP/MySQL extensions.

My issue is that, when I run this operation. Nothing happens,
it doesn't complete the operation and doesn't provide any errors
as are mysql_error(); is listed, aswell as commands to say, "Connection
Successful", etc.

I check my MySQL Command-line to see if anything has been
added to the database.table but nothing happens.

MySQL Administrator can access the MySQL server,
MySQL QueryBrowser can access the MySQL server.

It is operating off of, port 3307.

I am running the following code and I'd appreciate any commentation:

Code: Select all

<?php

if(isset($submit)):

$username = "max";
$password = "**********";
$hostname = "127.0.0.1:3307";

$table = 'losangeles';

$name = $_GET['name'];
$address = $_GET['address'];
$city = $_GET['city'];
$zip = $_GET['zip'];
$state = $_GET['zip'];

$db = mysql_connect($hostname, $username, $password);
if (!$db) {
	die ('Not connected : ' . mysql_error());
}
echo 'Connected successfully';

$db_selected = mysql_select_db('usmail', $db);
if (!$db_selected) {
	die ('Can\'t use usmail : ' . mysql_error());
}
$sql = "INSERT INTO $table
VALUES(NULL,'$name','$address','$city','$zip','$state')";

mysql_query($sql);

mysql_close($db_selected);

endif;
?>

<h3>Los Angeles County</h3>
<form action="data_in.php" method="post">

Name:<br />
<input type="text" name="name" />
<br /><br />
Address:<br />
<input type="text" name="address" />
<br /><br />
City:<br />
<input type="text" name="city" />
<br /><br />
Zip Code:<br />
<input type="text" name="zip" />
<br /><br />
State:<br />
<input type="text" name="state" />
<br /><br />
<br />
<input type="submit" name="submit" value="Submit!" />
</form>
Much Appreciation,

Max
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Did you try mysql_error() after the mysql_query() call?
maxfavela
Forum Newbie
Posts: 4
Joined: Tue Mar 28, 2006 11:25 am

Post by maxfavela »

I attempted to do so, it seems as if, php is not working with mysql.

Nothing was resolved.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

How about echoing $sql after you set it. Is it the right syntax? If you don't know, post it.
maxfavela
Forum Newbie
Posts: 4
Joined: Tue Mar 28, 2006 11:25 am

Post by maxfavela »

There was errors in my script, I have since re-written it.

Appreciate your help though feyd.
Post Reply