Re: using mysql in php problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Garth Hapgood - Strickland wrote:

I have created a registration page
http://www26a.your-server.co.za/matchm/registration4.php

On this page I have many fields, some of them pulling data out from my
database. I have a javascript validation scipt thats checks on submission of
the form to see if all required fields are filled in correctly.
IF thats the case it should submit the form. Which it isnt doing! It should
start with submission after the validation check is passed.


This part of the questions should be posted on a js list.

Then I check to see whether the BusinessName & BusinessOwner already exist,
if not then I am trying to to an insert (which it doesnt do either). Here is
the php code:
$errmsg = "";


$business_query = "SELECT BusinessName, BusinessOwner from business WHERE BusinessName = '$BusinessName' AND BusinessOwner = '$BusinessOwner'" ;

$result = mysql_query($business_query);


if (mysql_num_rows($result) > 0) {$errmsg .= "You are already registered at Match Makers";}



You will do yourself a great service by punctuating indenting your code properly. If you read the code of some open source php scripts you will find that they are so much easier to read.

else {

if (isset($submit) == "Register Now"){mysql_query("INSERT INTO business

(BusinessName, BusinessOwner, StreetAdress, Suburb, CityTown, ProvinceID,
StreetCode, PostalAddress, PostalCode, WebsiteAddress, IndustryID,
IndustryOther, ProductService, BusinessAge, AnnualTurnoverID,
EmpowermentProfileID, BEEScoreCardID, PreferredLocationID,
PreferredProductService, PreferredMatchPartner, PreferredIndustryID,
PreferredIndustryOther, PreferredAgeID, PreferredTurnoverID,
PreferredEmpowermentProfileID, DateRegistered, MarketSourceID)

VALUES

('" . $HTTP_POST_VARS['business_name'] . "', '" .
$HTTP_POST_VARS['street_address'] . "', '" . $HTTP_POST_VARS['suburb'] . "',
$city_town, $province_desc, $street_code, $postal_address, $postal_code,
$website_address, $industry_desc, $industry_other, $product_service,
$business_age, '', '', '', '', '', '', '', '', '', '',)");




See what i mean :-)

$id = mysql_insert_id();


..snipped ..

I am not sure where exactly I am going so wrong, and it really is starting
to drive me crazy!


The best thing to do is to liberally douse your code with error_log(mysql_error()) statement you will then start seeing error messages in your log (or your browser depending on your config) about what's going wrong.

As has often been pointed out echoing out the queries produced by your php script and running them through the mysql client usually helps too.

Regards
Garth





--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/         | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux