Jump to content

00stuff

Members
  • Posts

    65
  • Joined

  • Last visited

Everything posted by 00stuff

  1. Hi, I am trying to create an array from a mysql query that looks like this. $people = array( "8776546543" => "John Smith", "8779876543" => "John Dow", ); I need for that array to come from two columns of a mysql query and be placed on the $people variable. I am not sure how to do it. Can some one help me please?
  2. Hi guys, I am trying to create a script that gets a multiple select form selections and assign them to variables with php via the POST method. This is my code: <select name="search_commodity[]" multiple="multiple" size="3" style="position:absolute; top:80px; left:414px; " > <option value="all">All</option> <option value="none">None</option> <option value="some">Some</option> </select> Then after the form gets submited then it should go to this php page and the first value of the chosen options has to be assigned to the variable called commo. The problem is that is is not assigning anything. <?php $commo = $_POST['search_commodity[0]']; ?> Can someone help please? I can't figure it out.
  3. thank you very much, I will use error checking logic on my code from now on.
  4. I've been looking around and it seems like my code is correct. Does anyone see any mistakes?
  5. Hi guys, I am trying to UPDATE some records on a mySQL database but can't seem to find out why it is not working. This is my code. <?php $latitude = $_POST['lat_location']; $longitude = $_POST['long_location']; $unique_ID = $_POST['unique_ID']; include('connect2.php'); $query = mysql_query("SELECT * FROM user_location WHERE unit = '$unique_ID'"); $numrows = mysql_num_rows($query); if ($numrows == 1) { $query2="UPDATE user_location SET lat = '$latitude', long = '$longitude' WHERE unit = '$unique_ID'"; mysql_query($query2); $test = "matches"; } else { mysql_query("INSERT INTO user_location VALUES ('','$unique_ID','$latitude','$longitude')"); $test = "not match"; } echo $test . "<br />"; echo $numrows; ?> The script receives the data via the POST method and assigns it to variables. Then I query the database for one of those variables and check how many results are found. If 0 results are found then a new record is created on the database, but if there is 1 record found then the record that is found has to be UPDATED. When the result is 0 the scripts creates the new record fine, but if the result is 1 it doesn't update. I just can't figure out why. Any help will be greatly appreciated. Thanks in advanced,
  6. Yes, I just checked. The image was created successfully. Thank you.
  7. Hi guys I am trying to use image magick with php to draw an image but when i run the script it doens't show anything. All I get is an a blank page. Does anyone know if I am doing this right. Here is my code. <?php echo "<pre>"; system("type convert"); echo "</pre>"; ?> <br /> <br /> <br /> <br /> <br /> <?php exec("/usr/bin/convert -size 200x200 xc:black -stroke black -strokewidth 1 \\ -fill white -draw \"circle 100,100 100,10 \" \\ -fill black -draw \"circle 100,100 100,30 \" \\ -fill blue -draw \"circle 100,100 100,50 \" \\ -fill red -draw \"circle 100,100 100,70 \" \\ -fill yellow -draw \"circle 100,100 100,90 \" \\ -fill none -draw \"circle 100,100 100,20 \" \\ -fill none -draw \"circle 100,100 100,60 \" \\ -fill none -draw \"circle 100,100 100,80 \" \\ -fill none -draw \"circle 100,100 100,95 \" \\ -stroke white -fill none \\ -draw \"circle 100,100 100,40 \" circle.png"); ?> My results are these: convert is /usr/bin/convert I really need some help with this. I haven't been able to find anything online.
  8. I had already gone over those pages and examples. I know how to upload and download a file from the ftp. What I can't figure out is how to get the image from the ftp using php and then display it on a php page with the html tag <img src="">. I don't even know if i can use the <img src=""> tag or if it would have to be done a different way. I have been looking around the web for examples and I haven't found one yet.
  9. Hi guys, I have a page that lets you upload an image to a an ftp server. Now I am trying to create a page that will get those images and display them in a web page. I am trying to do this with php. Does anyone know if it can be done? Thanks guys,
  10. Well, I know it has to be uploaded with FTP, but I don't want to run an FTP server on the server that will contain the images and the server receiving the images is not a web server either. Just a computer with its own ip. Any way to do that? This is what I was doing. // get file attributes!!!!! $photoname1 = $_FILES['img_file']['name']; $tmp_name1 = $_FILES['img_file']['tmp_name']; $random1 = rand(1, 1000000); if ($photoname1) { // start upload process $photoname1 = $report_id . "_" . $random1 . "_" . $photoname1; // $location1 = "record_images/$photoname1"; $location1 = "http://192.168.1.3/qcapp_images/$photoname1"; move_uploaded_file($tmp_name1,$location1); } else { $location1 = ""; }
  11. Hi guys, I have a website that I created and it has the ability to upload images to a directory that is located in the same web server, but there are so many images now and it is taking too much space. What I am trying to do now is for the script to upload the images to a different server but don't want to run FTP on that second server if I don't need to. Does anyone know how I can do that? Thank you guys in advanced,
  12. Is there a way I can join both tables and then query only the results that meet all the criteria? I thought there was a way to do something similar. Any ideas at all?
  13. Hi guys, I'm trying to query two tables for different data and echo the results that match both tables. Here are the tables I have and the query I'm trying to run. (Table) qc_reports (Fields) id report_date report_lot_number report_po report_supplier report_buyer report_inspectedby report_pulptemprange report_carrierconditions report_supplierclaim report_carrierclaim report_temprecorder report_temprange_N report_temprange_M report_temprange_B report_suppliercontact report_contactedby report_time report_comments (Table) qc_lots (Fields) id report_id lot_temprange lot_commodity lot_rpcs lot_brand lot_terms lot_cases lot_orgn lot_estnum lot_avgnum This is the query that I'm trying to do. <?php $sql = "SELECT * FROM qc_reports, qc_lots WHERE "; if (!empty($start_date) and !empty($end_date)) $sql .= " qc_reports.report_date BETWEEN '$start_date' and '$end_date' AND "; if (!empty($search_fronteralot)) $sql .= " qc_reports.report_lot_number = '$search_fronteralot' AND "; if (!empty($search_buyer)) $sql .= " qc_reports.report_buyer = '$search_buyer' AND "; if (!empty($search_supplier)) $sql .= " qc_reports.report_supplier = '$search_supplier' AND "; if (!empty($search_po)) $sql .= " qc_reports.report_po = '$search_po' AND "; if (!empty($search_carrierconditions) and $search_carrierconditions != 'all') $sql .= " qc_reports.report_carrierconditions = '$search_carrierconditions' AND "; if (!empty($search_commodity) and $search_commodity != 'all') $sql .= " qc_lots.lot_commodity = '$search_commodity' AND "; if (!empty($search_inspectedby)) $sql .= " qc_reports.report_inspectedby = '$search_inspectedby' AND "; $sql = substr($sql, 0, -4); $query = mysql_query($sql); $numrows = mysql_num_rows($query); ?> RESULTS - <?php echo $numrows; ?> <hr> <table width='500'><tr><td><b>Date</b></td><td><b>Lot Number</b></td><td><b>PO</b></td><td> </td></tr> <tr> <td> </td> </tr> <?php while ($row = mysql_fetch_assoc($query)) { $id = stripslashes($row['id']); $report_lot_number = stripslashes($row['report_lot_number']); $report_po = stripslashes($row['report_po']); $report_date = stripslashes($row['report_date']); echo "<tr> <td>" . $report_date . "</td></td><td>" . $report_lot_number . "</td><td>" . $report_po . "</td><td><a href='view_report.php?id=" . $id . "'>View</a></td> </tr>"; } echo '</table><br><br><br><hr><br><br>'; } ?> All the variables are passed from a HTML form with $_POST. I need the search to work like this: If there is a value in a form field then the query gets appended with that value but when it gets to the $search_commodity it needs to search the second table (qc_lots) and check for the results. Any results that match have to be matched to the results from the first table (qc_reports) and display (echo) only qc_reports that match to both tables. The only common field is the report_id on the qc_lots table and the id on the qc_reports table. I'm stuck and need some guidance. Can someone help please?
  14. Hi guys. I am having a little trouble making a script work. What I am trying to do is run a PHP script after a form is submitted by the click of a div. This is my code: <form name='form_name' method='post' action=''> <input type='text' name='field1'> </form> <div onclick='document.form_name.submit();'>Click Me!</div> <?php if(isset($_POST['submit'])) { echo 'It workded!'; $field_1 = $_POST['field1']; } ?> That is not working though. I think they way I have it written it will need an actual submit button with the name 'submit'. Does anyone know how I can make this work without using an actual button and still using the div as a button? Thanks in advanced,
  15. I"m trying to write this variable on a php page with fwrite() but can't pass the \n in the mail() message. It removes the "\" and a letter n comes out. Can someone help please? My Code: $stringData2 = <<<EOF <?php \$name_first = \$_POST['name_first']; \$name_last = \$_POST['name_last']; \$phone = \$_POST['phone']; \$email = \$_POST['email']; \$to = "$receive_email"; \$subject = "Registration to $company_name"; \$message = "First Name: \$name_first \n Last Name: \$name_last \n Phone: \$phone \n Email: \$email"; \$from = "$receive_email"; \$headers = "From: \$from"; mail(\$to,\$subject,\$message,\$headers); echo "Mail Sent. Click <a href='register.php'>here</a> to go back!"; ?> EOF; How can I make sure the "\n" stays there?
  16. I"m trying to send email with PHP and go an Internal Error 500 on my server. I think it might be my script. Can some one tell me if ther is something wrong with it please? <?php $name_first = $_POST['name_first']; $name_last = $_POST['name_last']; $phone = $_POST['phone']; $email = $_POST['email']; $message2 = 'First Name: " . $name_first . " Last Name: " . $name_last . " Phone: " . $phone . " Email: " . $email . "'; $to = '" . $receive_email . "'; $subject = 'Registration to " . $company_name . "'; $message = $message2; $from = '" . $receive_email . "'; $headers = 'From:' . $from; mail($to,$subject,$message,$headers); echo 'Mail Sent. Click <a href="register.php">here</a> to go back!'; ?>
  17. I am running PHP version: PHP 5.2 I removed the single quotes and now I got this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/r/o/c/rochoa1/html/jssamples/register/index.php on line 30 this is the code: $stringData2 = <<<EOF <?php $name_first = $_POST['name_first']; $name_last = $_POST['name_last']; $phone = $_POST['phone']; $email = $_POST['email']; $message2 = 'First Name: " . $name_first . " \n Last Name: " . $name_last . " \n Phone: " . $phone . " \n Email: " . $email . "'; $to = '" . $receive_email . "'; $subject = 'Registration to " . $company_name . "'; $message = $message2; $from = '" . $receive_email . "'; $headers = 'From:' . $from; mail($to,$subject,$message,$headers); echo 'Mail Sent. Click <a href="register.php">here</a> to go back!'; ?> EOF; line 30 is: $name_first = $_POST['name_first']; What is wrong now?
  18. That is what everyone seems to think but when I put my typing cursor right after <<<'EOF' and press the delete key it just gives me <<<'EOF'<?php and then the rest of the code and that still gives me the same error. Do you think it could be something else?
  19. I keep on getting this error but I can't figure out what's wrong. Line 28 is : $stringData2 = <<<'EOF' <?php $stringData2 = <<<'EOF' <?php $name_first = $_POST['name_first']; $name_last = $_POST['name_last']; $phone = $_POST['phone']; $email = $_POST['email']; $message2 = 'First Name: " . $name_first . " \n Last Name: " . $name_last . " \n Phone: " . $phone . " \n Email: " . $email . "'; $to = '" . $receive_email . "'; $subject = 'Registration to " . $company_name . "'; $message = $message2; $from = '" . $receive_email . "'; $headers = 'From:' . $from; mail($to,$subject,$message,$headers); echo 'Mail Sent. Click <a href="register.php">here</a> to go back!'; ?> EOF; ?> Can someone help me please?
  20. Does anyone kow how this <<<'EOF' works? Do I have to use curly brackets after like this? $variable = <<<'EOF' { } EOF;
  21. I'm getting this error. Parse error: syntax error, unexpected T_SL in /home/content/r/o/c/rochoa1/html/jssamples/register/index.php on line 28 I don't get it on my WAMP server but when I uploaded it to my shared hosting account it gives me this error. Does anyone know why? This is Line 28: $stringData2 = <<<'EOF'
  22. I'm getting this error and I can't figure out why! Can someone help me please? Error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\Registration\index.php on line 32 My Code: <html> <head> <title>Registration Page</title> <script type="text/javascript"> function validateForm() { var company_name=document.forms["myForm"]["company_name"].value var receive_email=document.forms["myForm"]["receive_email"].value if (company_name==null || company_name=="" || receive_email==null || receive_email=="") { alert("Please fill in all information!"); return false; } } </script> <?php if (isset($_POST['submit'])){ $company_name = $_POST['company_name']; $receive_email = $_POST['receive_email']; $stringData2 = " <?php $name_first = $_POST['name_first']; $name_last = $_POST['name_second']; $phone = $_POST['phone']; $email = $_POST['email']; $message2 = 'First Name: " . $name_first . " \n Last Name: " . $name_last . " \n Phone: " . $phone . " \n Email: " . $email . "'; $to = '" . $receive_email . "'; $subject = 'Registration to " . $company_name . "'; $message = $message2; $from = '" . $receive_email . "'; $headers = 'From:' . $from; mail($to,$subject,$message,$headers); echo 'Mail Sent. Click <a href='register.php'>here</a> to go back!'; ?> "; $ourFileName = "register_ac.php"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fwrite($ourFileHandle, stripslashes($stringData2)); fclose($ourFileHandle); $stringData = " <html> <head> <title>" . $company_name . " Registration</title> <script type='text/javascript'> function validateForm() { var name_first=document.forms['registration_form']['name_first'].value var name_last=document.forms['registration_form']['name_last'].value var phone=document.forms['registration_form']['phone'].value var email=document.forms['registration_form']['email'].value if (name_first==null || name_first=='' || name_last==null || name_last=='' || phone==null || phone=='' || email==null || email=='') { alert('Please fill in all information!'); return false; } } </script> </head> <body> <center> <!-- This is the table that contains the registration form! --> <form name='registration_form' method='post' action='register_ac.php' onsubmit='return validateForm()'> <table bgcolor='#cccccc'> <tr> <td> <table border='0' cellspacing='0' cellpadding='5' width='320'> <tr> <td colspan='2' align='center' bgcolor='white'><h2>" . $company_name . " Registration Page</h2></td> </tr> <tr> <td colspan='2' align='center' bgcolor='white'><font size='2'>All fields are required to submit this form.</font></td> </tr> <tr> <td colspan='2'><hr></td> </tr> <tr> <td><b>First Name:</b> </td><td align='right'><input type='text' name='name_first' size='30'></td> </tr> <tr> <td><b>Last Name:</b> </td><td align='right'><input type='text' name='name_last' size='30'></td> </tr> <tr> <td><b>Phone Number:</b> </td><td align='right'><input type='text' name='phone' size='30'></td> </tr> <tr> <td><b>Email:</b> </td><td align='right'><input type='text' name='email' size='30'></td> </tr> <tr> <td colspan='2'><hr></td> </tr> <tr> <td> </td><td align='right'><input type='submit' name='submit' value='Register'></td> </tr> </table> </td> </tr> </table> </form> <!-- End of the table containing the Registration form! --> </center> </body> </html>"; $ourFileName = "register.php"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fwrite($ourFileHandle, $stringData); fclose($ourFileHandle); } else { echo " </head> <body> <center> <form name='myForm' method='post' action='' onsubmit='return validateForm()'> <table> <tr> <td colspan='2' align='center'><h2>Registration Configuration Form</h2></td> </tr> <tr> <td>Company Name: </td><td><input type='text' name='company_name' size='30'></td> </tr> <tr> <td>Email: </td><td><input type='text' name='receive_email' size='30'></td> </tr> </table> </form> </center> </body> </html>"; } ?>
  23. Found the problem. I was gettting the md5 of ' ' and I should of done that only if the variable $password was not empty in the first place. I added. <?php if (!emtpy($password)) { $passwrod = md5($password); } ?> That fixed my problem.
  24. I don't want to update all of the fields. I want the script to check if the field has text on it and if it does then to update that field to the database. I changed the script to: <?php if (!empty($password)) { $queryreg = mysql_query("UPDATE user_acl SET password = '$password' WHERE id = $id "); } ?> When I submit the form the field that passes the data to the variable $password was empty and the UPDATE query still modified the entry to the md5 hash of nothing. Do you guys understand what I'm trying to do now?
×
×
  • 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.