Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9254709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:32:23+00:00 2026-06-18T11:32:23+00:00

Here is my code: mysql_connect(localhost, username, password) or die(mysql_error()); mysql_select_db(database) or die(mysql_error()); $method =

  • 0

Here is my code:

mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());

$method = $_POST["method"]; //dropdown box
$category = $_POST["category"]; //dropdown box
$email = mysql_real_escape_string($_POST["email"]);
$companyname = mysql_real_escape_string($_POST["companyname"]);
$phone = mysql_real_escape_string($_POST["phone"]);
$address = mysql_real_escape_string($_POST["address"]);
$state = mysql_real_escape_string($_POST["state"]);
$zip = mysql_real_escape_string($_POST["zip"]);

$salt = $email;
$length = 10;
$temporarypassword =  
substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),  
0, $length);
$temp_encrypted_password = sha1($salt.$temporarypassword);

$addcompany = mysql_query("INSERT INTO company (`method`, `category`,  
`email`, `password`, `companyname`, `phone`, `address`, `state`, `zip`, `ratingcount`, 
`ratingscore`, `usage`, `date`)
VALUES 
('$method','$category','$email','$temp_encrypted_password',
'$companyname','$phone','$address','$state','$zip','0','0','0',CURDATE()) ")
or die(mysql_error());

if (mysql_fetch_array($addcompany)) {

$to = "$email";
$subject = "Your Temporary Password";
$message = "Your temporary password is: <b>$temporarypassword;</b>. Sign in and   
update your password as soon as possible.";
$header = "From: email@gmail.com\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
mail($to,$subject,$message,$header);

$message = "Company Added";

}

}
}

So, the sql statement executes just fine and is entered into my database just as I want it. However, the IF statement for if $addcompany returns true must be returning false, because nothing inside the statement executes. I use this check for mysql_fetch_array this way on other parts of my site and it works fine so I’m curious as to why it isn’t returning in this case.

FYI I’m looking into PDO for those who will say it. lol I already got reamed for it on a previous post today.

Thanks for your time, I appreciate it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:32:24+00:00Added an answer on June 18, 2026 at 11:32 am

    The php-doku declares, that for all INSERT-statements mysql_query returns a boolean, whether the statement was successfully executed.
    So you don’t need to

    if (mysql_fetch_array($addcompany)) {
    

    But simply

    if ($addcompany) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my code <?php $host = 'localhost'; $username = 'sam_sam'; $password = '[censored]'; $name
here is the code <?php session_start(); if(!isset($_SESSION['user_name'])) { header('Location: login.php'); } $conn = mysql_connect(localhost,
Here is my code- <?php $con = mysql_connect('db', 'table', 'p/w'); if (!$con) { die('Could
here is my code... loginscript.php <?php ini_set('display_errors', true); $host=localhost; // Host name $username=root; //
Here my code, I need to insert into mysql database I have mysql,php,android 1)
I am getting this error here is my code if(isset($_POST['submit'])) { $projTit=mysql_escape_string($_POST['projecttitle']); $projCat=mysql_escape_string($_POST['projectcategory']); $budget=intval(mysql_escape_string($_POST['budget']));
I'm getting Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'username'@'localhost' (using password: NO) Here's
Here's the code: mysql_query(DELETE . $_GET['id'] . FROM forum_favorites WHERE thread_id=' . $_GET['id'] .
here is my code i am using to fetch mysql result from 4 different
Here's some code: OdbcConnection connection = new OdbcConnection(@DRIVER={MySQL ODBC 5.1 Driver};SERVER= + ip +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.