Insert several code cards does not not (php)

Using PHP am attempting to insert multiple records of 2 columns (recID, ingredientID) from
a static variable (recID) and the multiple values of a form's list object.

Here's the code from the form...
<h3>Main Ingredients</h3>
    <select name="ingredID[]" size="20" multiple="MULTIPLE">

Here's the header code that's not working:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  for ($i = 1; $i <= $_POST["ingredID"].length; $i++) {
     $insertSQL = sprintf("INSERT INTO ingredxrec (ingredID, recID) VALUES (%s, %s)",
                       GetSQLValueString($_POST['ingredID'][$i], "int"),
                       GetSQLValueString($_POST['recID'], "int"));

  mysql_select_db($database_conRecipes, $conRecipes);
  $Result1 = mysql_query($insertSQL, $conRecipes) or die(mysql_error());
     }
  $insertGoTo = "showmainingred.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

Can someone point out the trouble?
THANKS
Steve

There are a few problems. First of all, it is more efficient to select the database outside the loop. Secondly, you mix JavaScript with PHP syntax. To get the length of an array, use count(). Again, it is more effective to do this outside the loop.

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {  mysql_select_db($database_conRecipes, $conRecipes);  if (is_array($_POST["ingredID"])) {    $len = count($_POST["ingredID"]);    for ($i = 1; $i <= $len; $i++) {     $insertSQL = sprintf("INSERT INTO ingredxrec (ingredID, recID) VALUES (%s, %s)",                       GetSQLValueString($_POST['ingredID'][$i], "int"),                       GetSQLValueString($_POST['recID'], "int"));

    $Result1 = mysql_query($insertSQL, $conRecipes) or die(mysql_error());     } // end of loop  } // end of second if statement  $insertGoTo = "showmainingred.php";  if (isset($_SERVER['QUERY_STRING'])) {    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";    $insertGoTo .= $_SERVER['QUERY_STRING'];  }  header(sprintf("Location: %s", $insertGoTo));}

Tags: Dreamweaver

Similar Questions

  • The SIM card inserted in this iPhone does not appear to be supported.

    The SIM card inserted in this iPhone does not appear to be supported.

    The SIM card that you have currently installed in this iPhone is a carrier that is not supported in the title of the activation policy that is currently assigned by the activation server. This isn't a problem with the hardware with the iPhone. Please insert a different SIM card of a carrier supported or to ask that this iPhone be unlocked by your operator. For more information, contact Apple.

    < re-titled by host >

    Not sure what your question is. The error message is clear: the device is locked to another carrier. It must be unlocked before you can use the SIM card, you try to use. Contact the carrier to get it resolved. Only they can help you with this.

    See you soon,.

    GB

  • I got a redemption of my school code in the United States, but I couldn't use it. It shows that this card does not correspond to my Adobe ID because of problem of country or region.

    I got a redemption of my school code in the United States, but I couldn't use it. It shows that this card does not correspond to my Adobe ID because of problem of country or region.

    A few changes/Verify account https://forums.adobe.com/thread/1465499 links that can help

    -html http://helpx.adobe.com/x-productkb/policy-pricing/change-country-associated-with-adobe-id.

    If you have a US redemption code, your profile must also show you in the United States

  • Satellite A200-1VM - SD card does not work

    SD card does not start.
    I already have SP1 and in Device Manager SD card appears with "!" when a card is inserted and is not, when it's empty.
    When I insert a card inside it says does not start code 10 but I see the led blink whenever I put a card inside.

    Can anyone help?

    Error code 10 said that the SD card driver was not installed correctly or device couldn t load the driver.

    In any case, you should definitely try to reinstall the driver from SD card.
    First go to Device Manager and uninstall the old drivers.
    Then install the driver again, downloaded from the page of European driver of Toshiba.

    Finally, restart the laptop and try again!

    Good luck

  • Menu to transfer the photos on my memory card does not appear, is there another way I can do?... Without using the usb cord...

    Menu to transfer the photos on my memory card does not appear, is there another way I can do?... Without using the usb cord... He lost. :/

    The following steps may be worth a try:

    Insert your memory card into your Media Player...

    Reach... Start / computer...

    What is the memory card show as a drive letter? (if your Media Player)
    has several slots, there will be several "hard drives" listed... the
    SD card will be one of them)

    If_Yes_right click on the drive letter correct and in the menu... Choose...
    Open... now you should see the directory of the memory card or to explore.

    From there you should be able to drag and drop or copy and paste the
    files in a folder on your hard drive.

    Also... the following items may be worth a visit:

    Windows Vista-
    Troubleshoot AutoPlay
    http://Windows.Microsoft.com/en-us/Windows-Vista/Troubleshoot-AutoPlay-problems

    Windows Vista-
    How to change the auto run settings
    http://Windows.Microsoft.com/en-us/Windows-Vista/Change-AutoPlay-settings

    Windows Vista-
    AutoPlay: Frequently asked questions
    http://Windows.Microsoft.com/en-us/Windows-Vista/AutoPlay-frequently-asked-questions

  • Satellite P850-133 - extended graphics card does not work

    Hello!

    I got my 2 new p850-133 and they have reinstalled with a new copy of Windows 7, and then the extended graphics card does not work, he said: "code 10" failed to start, what to do, the hd4000 intel integrated works really well.

    Hello

    The laptop is equipped with a GPU NVIDIA® GeForce® GT630M.
    The European driver Toshiba page provides 3 different display drivers.

    2 drivers for nVidia GPU (v296.0 for the 3D and v296.01) and one for Intel (v 8.15.10.2712).
    You must install the Intel driver and one of the nVidia drivers.

  • HP Photosmart ENVY: upgrade to Windows 10 now my SD card does not work!

    I bought my HP photosmart envy a few months ago.  I signed up for the free update to windows 10.  I had no problem until yesterday, I noticed that my SD card does not work.  When I insert an sd card that I know has the pictures, there is no pop up asking me what I want to do with photos.  When I go into my files to find that the external storage device manually there is no such folder showing.  What should I do?  I use my card sd slot all the time and now its useless.

    Hello:

    Please unzip the file in its folder (right click on the file zipped, select extract).

    Then after that he extracted, open the folder and then inside is a different folder, open that then double-click to run the Setup file of blue, then the driver will be installed.

  • Graphics card does not work on the Satellite L850 PSKFWA

    Hello

    I have a Satellite XC 250895 Q. Windows 8 keeps giving me a message that my graphics card does not work correctly.
    I go to the Radeon website and click on the appropriate boxes and let Radeon check my system to see if the drivers are up to date. He tells me that I have to download something (?) New driver) but when I do it tells me there is a problem with the compatibility with my system.

    I haven't noticed any problem with the graphics.
    It may be a Radeon problem, but what I have on my system, which was installed at the factory.

    Thanks for everything back
    Hetty

    + The message was edited: model nr. Add the object +.

    Can you please tell us once more what model of laptop you have exactly?
    Are you using the original Win8 preinstalled?

  • Wireless network card does not appear in the Device Manager on Satellite L50 - B - 1 DM

    Hello!
    I bought just new Satellite L50 - B - 1 DM, model number PSKTCE and installed on Windows 7 Professional SP1 64 bit. He came without OS installed and without driver installation disk.
    Problem is that Wlan card does not appear in Device Manager.

    For my Toshiba support model are 37 drivers and programs. I have already installed: Windows 7 Professional 64-bit, all updates to Windows that appeared, SP 1, driver LAN, Toshiba Value added Package. And I tried to install all wlan drivers 4 in the list of "tool utility Intel ' also.
    Does not always display any connection without wireless WLAN card. Pressing Fn + F12 does not change. In "Network connections" is the only connection - LAN. No WLAN, no bluetooth.

    I have "Other devices" in Device Manager with yellow marks on: network controller; PCI device; PCI Simple Communication controller; SM Bus controller. USB controller; Unknown device (with Microsoft ACPI - compliant system location) and video controller.

    Any help would be welcome. Thanks in advance

    If it's not bad - just saw that my BIOS is version 1.70

  • Satellite 5000 with Windows XP, Service Pack 1 is installed and now my sound card does not work

    Everyone knows this problem.

    I have a 5000 Satellite with Windows XP. I installed SP1 and now my sound card does not work.

    Any ideas out there?

    Does anyone have this problem?

    I reinstalled the Yamaha drive a couple of times and always the same: no sound?

    I bought this unit in Holland and it was great until the problem of Service Pack. I heard that Comcom was a dealer right here. Maybe I'll have to make to them, if I can't help here?

  • P20-552: 2 GB SD card does not work.

    I have a P20-552 (PSP26E-025E9-S4), which is about 18 months old. I recently bought a digital camera (IxUS 750) barrel with a 2 GB Sandisk Ultra II SD card and the combination does not work well. Although I can transfer images from the camera to my Toshiba laptop with a USB cable, sometimes, I would use the SD slot on the laptop, but there seems to be a problem: seconds after pressing home the SD card in the slot, I get the message "disk is not formatted - do you want to format it now?". I said OK but then I get the message "cannot be formatted disk in drive E".

    The card continues to work perfectly fine in my camera and on my iPaq Pocket PC. In the Toshiba SD card works quite happy with Sandisk card of 256 MB SD, which is usually in my PDA.

    Anyone has an idea why the 2 GB card does not work in the Toshiba? It's updating a driver - I watch the other day but I couldn't find anything that seemed appropriate, but I might well have forgotten something...

    I'm running XP Home Edition (SP2) and are automatic updates IT. I have Norton Virus and Zone Alarm running and have no problems with other software/applications - at least, no problem, as someone suggested to suck my laptop overheating a few weeks ago ;-)

    Thank you, Brian.

    It seems that the unit doesn t support this card.
    See your user manual. You will find an information that this device supports only the following SD card formats: Mo 8/16/32/64/128/256 and 512

    According to this document, the 2 GB are high.

  • Sound card does not work after upgrade to XP Pro

    I need help - Microsoft participated three times without result. After that I updated to XP pro that my SigmaTel C Major sound card does not work. Done all the usual uninstall the driver, update driver etc. No results. When I go into the properties of audio devices, midi and mixer IE driver I see a status message: active but device not started

    Any ideas on how to solve it is greatly appreciated.

    Hello

    Sorry but I have no explanation for this. I can recommend you to remove the sound card in Device Manager, then restart the unit. After reboot, the sound card must be recognized and installed properly.

    It will be interesting to know what model of laptop you have.

  • HP2310i: New (ASUS GEForce GTX 750Ti) graphics card does not not on HP 2310i

    Hi all

    Help, please! I can't get my new graphix card to work with my HP 2310i :-(

    Basic unit of HP: Pavilion

    Model: p6320uk i5 CPU 3 .2GHz

    RAM: 6 GB

    Screen: HP 2310i

    Windows: 7 (64-bit)

    Card: ASUS GEForce GTX 750Ti

    I swapped the old card and put in the new (I know what I'm doing with this as much before). Connect the plug of the correct video adapter for the graphics card is: DVD-D/VGA. Everything turns on and all I get is...

    DVI: NO SIGNAL

    VGA: NO SIGNAL

    I can't add the new GEForce drivers from the disk because it needs the map in situ.

    What Miss me? What can I do? I am doing something stupid?

    Help! :-D

    Thanks Jowler

    Jowler, welcome to the forum.

    You have shown two different models in your thread.  I used the p6329uk.  The reason that the video card does not work is that it requires UEFI in the motherboard instead of a standard BIOS.  HP didn't start using UEFI until mid-October 2012.  Your computer was released on January 15, 2010.  Therefore, the GTX 750ti will not work.  The last series of video cards that does not need UEFI was 640 gt.

    Please click on the Thumbs up button '+' if I helped you and click on "Accept as Solution" If your problem is resolved.

  • Hybrid Analog/DVB-T card does not work - Qosmio F50

    Hybrid Analog/DVB-T card does not (Windows Vista Home Premium).

    Channel zero came after scanning with Media Center. Sent to the hardware engineers.
    Tha card has been tested in a "fresh load of Windows" and worked well.

    It was suggested to clean and reload Windows.
    I made and tested with and without having to download Service Pack 1. Still does not work. Driver has also been updated (2.3.3.21).

    Any suggestions?

    Thank you

    Hello

    First of all, you should test the portable DVB - T with Toshiba s card preinstalled Vista.
    Everything has been set up and should work fine

    I think that it s not Analog/DVB-T Hybrid card problem.

    Maybe the DVB - T signal is too weak and therefore you do not find the TV channels using this card.

    In my country and the region, the DVB - T signal is really weak and I need a DVB - T antenna to receive the signal and the channels!

  • Error message - Toshiba flash cards does not react

    On the top of my screen, I see a message that toshiba flash cards does not react. Where can I change this? I can't close the other windows because this message gets in the way.

    Tamara

    Hello

    Utility of Toshiba Flash Cards control the Fn keys.
    You should check and if necessary should deactivate and activate the card Programs\Toshiba\Flash card utility Flash

    If this does not help, reinstall again the Support of Flash memory card utility.

    Welcome them

Maybe you are looking for