Jump to content

atticus

Members
  • Posts

    176
  • Joined

  • Last visited

Everything posted by atticus

  1. I found the alter command...appreciate it everybody
  2. thanks...I have never tried to change the name of a table in phpmyadmin and I don't see how. The back ticks aren't making a difference
  3. I am getting syntax error for the following code. I can't seem to find the problem: Error, insert query failedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order (cust_id, last_name, first_name, middle_name, suffix, address_1, address_2' at line 1 $query = "INSERT INTO order (cust_id, last_name, first_name, middle_name, suffix, address_1, address_2, city, state, zip, gender, race, dob, ssn, search_area_state, search_area_county, city_search, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, type_service, notes) VALUES ('$cust_id', '$last_name', '$first_name', '$middle_name', '$suffix', '$address1', '$address2', '$city', '$state', '$zip', '$gender', '$race', '$dob', '$ssn', '$search_area_state', '$search_area_county','$city_search', '$s1', '$s2', '$s3', '$s4', '$s5', '$s6', '$s7', '$s8', '$s9', '$s10', '$s11', '$s12', '$s13', '$s14', '$s15', '$type_service', '$notes');"; mysql_query($query) or die('Error, insert query failed' . mysql_error());
  4. I am updating mysql server and having problems with the syntax, the data is posting form the form: <?php include("config.php"); if(isset($_POST['submit'])) { $id = mysql_escape_string($_POST['cust_id']); $lastname = mysql_escape_string($_POST['last_name']); $firstname = mysql_escape_string($_POST['first_name']); $username = mysql_escape_string($_POST['username']); $password = mysql_escape_string($_POST['password']); $phone = mysql_escape_string($_POST['phone']); echo $id, $lastname, $firstname, $username, $password, $phone; $query = "UPDATE client SET last_name = '$lastname', first_name = '$firstname', username ='$username', password = 'PASSWORD('$password')', phone = '$phone' WHERE cust_id = '$id'"; mysql_query($query) or die('Error, insert query failed' . mysql_error()); error: Error, insert query failedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'jjjjjjjjj')', phone = 'jjjjjjjjj' WHERE cust_id = '18'' at line 4
  5. thanks...I did find the query was not working because of a typo...
  6. I am getting an error from the following code <?php include("config.php"); $sql = "SELECT clients.*,company.company_name FROM client,company WHERE client.com_id = company.com_id ORDER BY company_name"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "<div class=\"result\"><h4>".$row['company_name']." </h4><br /><a href=\"com_editor.php?com_id=$row[com_id]\">Edit Company</a> | <a href=\"com_delete.php?com_id=$row[com_id]\">Delete Company</a><br />"; echo "<label>Name:</label> ".$row['lastname'].", ".$row['firstname']."<br /> "; echo "<label>User Name:</label> ".$row['username']."<br /> </div>"; error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in line: while($row = mysql_fetch_array($query)) {
  7. thanks...you were right about the: $id = $_POST['$IDrow']; After I commented it out and used the other variable, it worked perfectly...again, thanks
  8. when I print the results from this code: $query = "SELECT com_id FROM company where company_name = company_name"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $IDrow = $row['com_id']; I get the company id. But the query is not inserting it into the database. Did I do my variable wrong?
  9. thanks...here is what I have got so far but I am not getting the value into the table <?php if(isset($_POST['add'])) { include 'config.php'; $query = "SELECT com_id FROM company WHERE company_name = company_name"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $IDrow = $row['ID']; //you now have the ID of the company from the table $id = $_POST['$IDrow']; $lastname = $_POST['lastname']; $firstname = $_POST['firstname']; $phone = $_POST['phone']; $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; $query = "INSERT INTO client (last_name, first_name, phone, username, password, email, com_id) VALUES ('$lastname', '$firstname', '$phone', '$username', PASSWORD('$password'), '$email', '$id');"; mysql_query($query) or die('Error, insert query failed' . mysql_error());
  10. Here is the logical flow of what I am trying to do: -I have two tables:company, client -The first table (company) contains information about a company that is a customer -The second table (client) contains the information about the users from that company. -I want to assign a client access and associate that client with a company -to avoid problems if the name of the company or the client changes, I am using an integer ID which is primary in MySQL for the company id. -When I created the form to add a user, I do a query of the company table and create a drop down menu listing the names of the company in the company table. My question: How do I convert that company name back to the com_id to be inserted into the client table. I haven't posted code because my form works fine as long as I just insert the company name, I just don't know how to tell it to insert the id associated with the company name as opposed to the company name. Thanks in advance.
  11. Thanks...you were right about the PHP_SELF in the action=. I have the GET ID in the IF function which I did not include in the original posting,(trying to comply with forum rules about entire scripts). That fixed my problem. I will take your advice on standardizing all of my php opening brackets. Thanks again
  12. I thought my problem was solved. But when I update the record in the first row, there is no problem. However, for other rows it doesn't update the database. No mysql errors are being reported. The info. in the form is correct, and I echoed the information from the form so I know my data is good going into the update query. Any suggestions?
  13. thanks. The "." was the problem. However I am still having an issue. All of the input fields are working except for 'company_name'. when I echo $name I get the data from the form. But its not updating in the database. No errors.
  14. When I submit the form, I get my "company updated successfully message, but alas, it is not updated successfully. I am not receiving any errors from the update mysql query. I have tried to debug it by echoing the info from the form. That info is there and being put into the variables. Form: <?php $result = mysql_query("SELECT * FROM company WHERE com_id='$_GET[com_id]' ") or die('Error, query failed : ' . mysql_error()); while($myrow = mysql_fetch_assoc($result)) { $id = $myrow['com_id']; $name = $myrow['company_name']; $address1 = $myrow['address_1']; $address2 = $myrow['address_2']; $city = $myrow['city']; $state = $myrow['state']; $zip = $myrow['zip']; $phone = $myrow['phone']; ?> <br> <h3>Edit Company Profile :: <?php echo $name; ?> </h3> <form method="post" action="<?php echo $PHP_SELF ?>"> <input type="hidden" id="com_id" name="com_id" value="<? echo $id; ?>"> Name: <input type="text" name="company_name" size="40" id="company_name" maxlength="255" value="<? echo $name; ?>"> <br> Address 1: <input type="text" name="address_1" size="40" id="address_1" maxlength="255" value="<? echo $address1; ?>"> <br> Address 2: <input name="address_2" type="text" size="40" id="address_2" maxlength="255" value="<? echo $address2; ?>"> <br> City: <input name="city" type="text" size="40" id="city" maxlength="255" value="<? echo $city; ?>"> <br> State: <input name="state" type="text" size="40" id="state" maxlength="255" value="<? echo $state; ?>"> <br> Zip: <input name="zip" type="text" size="40" id="zip" maxlength="255" value="<? echo $zip; ?>"> <br> Phone: <input name="phone" type="text" size="40" id="phone" maxlength="255" value="<? echo $phone; ?>"> <input type="submit" name="submit" value="Update"> </form> The query for the form: <?php if(isset($_POST['submit'])) { $id = mysql_escape_string($_POST['com_id']); $name = mysql_escape_string($_POST['company_name']); $address1 = mysql_escape_string($_POST['address_1']); $address2 = mysql_escape_string($_POST['address_2']); $city = mysql_escape_string($_POST['city']); $state = mysql_escape_string($_POST['state']); $zip = mysql_escape_string($_POST['zip']); $phone = mysql_escape_string($_POST['phone']); mysql_query(" UPDATE company SET company_name = '$name', address_1 = '$address1', address_2='$address2', city = '$city', state = '$state', zip = '$zip', phone = '$phone' WHERE com_id='.$_GET[com_id]'") or die('Error, query failed : ' . mysql_error()); echo "<b>Thank you! Company UPDATED Successfully!<br />You will be redirected in 4 seconds"; echo "<meta http-equiv=Refresh content=4;url=companies.php>"; } Thanks
  15. thanks man...one little coma...
  16. I added the "." because it is an integer, however now I am getting the following error, same just with "." included Error, query failed : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE com_id='.1'' at line 1 <?php if(isset($_POST['submit'])) { $id = mysql_escape_string($_POST['com_id']); $name = mysql_escape_string($_POST['company_name']); $address1 = mysql_escape_string($_POST['address1']); $address2 = mysql_escape_string($_POST['address2']); $city = mysql_escape_string($_POST['city']); $state = mysql_escape_string($_POST['state']); $zip = mysql_escape_string($_POST['zip']); $phone = mysql_escape_string($_POST['phone']); $result = mysql_query("UPDATE company SET company_name='$name', address_1 = '$address1', address_2 = '$address2', city ='$city', state ='$state', zip ='$zip', phone ='$phone', WHERE com_id='.$_GET[com_id]'") or die('Error, query failed : ' . mysql_error()); echo "<b>Thank you! User UPDATED Successfully!<br />You will be redirected in 4 seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; }
  17. I'm a noob, but I did have a similar problem with sessions and logins. I learned from someone on this forum that if the page is encoded in: UTF-8, that it will sometimes give that error. When I changed my encoding in my text editor to ANSI, my problem was solved. Maybe it will work for you?
  18. I just looked at this line: $input = mysqli_real_escape_string($databaseConnect, $input); my bad...I have never used a mssql server...I treat ms like the plague
  19. Error: Error, query failed : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE com_id = '1'' at line 1 $result = mysql_query("UPDATE company SET company_name='$name', address_1 = '$address1', address_2 = '$address2', city ='$city', state ='$state', zip ='$zip', phone ='$phone', WHERE com_id='$_GET[com_id]'") or die('Error, query failed : ' . mysql_error()); I can't find the syntax error...any ideas?
  20. shouldn't Line 170 is: $input = mysqli_real_escape_string($databaseConnect, $input); be: Line 170 is: $input = mysql_real_escape_string($databaseConnect, $input);
  21. thanks...I changed the file format in my editor to ANSI and the problem was solved. I really appreciate the help and I will be researching ob_clean(); thanks for the tip.
  22. thanks everyone...there was no whitespace at the top...however I did change some of the format, but now I am getting a completely blank screen or this error: Warning: Cannot modify header information - headers already sent by (output started at /html/cms/cms/admin/index.php:1) in //html/cms/cms/admin/index.php on line 11 <?php ob_clean(); ob_start(); session_start(); // is the one accessing this page logged in or not? if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) { // not logged in, move to login page ob_clean(); header('Location: login.php'); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> I did change the charset=utf-8 to ANSI/ASCII in the html, but it did not seem to make a difference. For some reason it is not redirecting to login.php
  23. I am getting the following errors for a session/login script. errors: Warning: session_start(): Cannot send session cookie - headers already sent by (output started at ..../html/cms/cms/admin/index.php:1) in ..../html/cms/cms/admin/index.php on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at ...html/cms/cms/admin/index.php:1) in ..../html/cms/cms/admin/index.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at ..../html/cms/cms/admin/index.php:1) in .../html/cms/cms/admin/index.php on line 8 <?php session_start(); // is the one accessing this page logged in or not? if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) { // not logged in, move to login page header('Location: login.php'); exit; } ?>
  24. your right, CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE CLEAN CACHE...maybe I'll remember now. thanks for going through the trouble
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.