Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
N

nathionice

@nathionice
About
Posts
9
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • MySQL syntax error near ''
    N nathionice

    I have changed the code to the following and decremented array count by 1 on $c = count($headerTable)-1; and it seems to work Thanks a lot guys for helping

    $query = "INSERT INTO ".$table."(FileIdentifier, Version, ReceiverIdentifier, Date, Time, FileGenerationNumber) VALUES";
    	
    	$c = count($headerTable)-1;
    	echo "headerTable Count = ".$c;
    	 $numberOfLoops=0;
    	for($i = 0; $i < $c; $i += 6) 
    	{
    		// Add the next batch of values to the query string
    		if($i==0)
    		{
    			$query.= "('".$headerTable\[$i\]."','".$headerTable\[$i+1\]."','".$headerTable\[$i+2\]."','".$headerTable\[$i+3\]."','".$headerTable\[$i+4\]."','".$headerTable\[$i+5\]."')";
    		}
    		else
    		{
    			$query.= ", ('".$headerTable\[$i\]."','".$headerTable\[$i+1\]."','".$headerTable\[$i+2\]."','".$headerTable\[$i+3\]."','".$headerTable\[$i+4\]."','".$headerTable\[$i+5\]."')";
    		}
    		echo $query; 
    		echo 'The number of loops';
    		echo $numberOfLoops++;
    		$result = mysql\_query($query) or die('Query failed: ' . mysql\_error());		
    		
    		
    	}
    	return true;
    	echo 'The number of loops';
    	echo $numberOfLoops++;
    }
    
    Linux, Apache, MySQL, PHP database help mysql sysadmin data-structures

  • MySQL syntax error near ''
    N nathionice

    I get the following error headerTable Count = 7INSERT INTO HeaderRecord(FileIdentifier, Version, ReceiverIdentifier, Date, Time, FileGenerationNumber) VALUES('SOF','1','1500','19970519','112904','1 ')INSERT INTO HeaderRecord(FileIdentifier, Version, ReceiverIdentifier, Date, Time, FileGenerationNumber) VALUES('SOF','1','1500','19970519','112904','1 '), ('','','','','','')Query failed: Duplicate entry '1' for key 2 Below is the rewritten code(whole code) as per your suggestions

    Linux, Apache, MySQL, PHP database help mysql sysadmin data-structures

  • MySQL syntax error near ''
    N nathionice

    I honestly do not understand why it has to run(iterate) more than once as $i += 6 will make $i < $c false just after a single iteration. I'm pulling my hair here, i really need this sorted as in yersterday.

    Linux, Apache, MySQL, PHP database help mysql sysadmin data-structures

  • MySQL syntax error near ''
    N nathionice

    Thanks for the response. I am trying to create one record but the query is repeated more than once. I don't know where in my code do i repeat the query.

    Linux, Apache, MySQL, PHP database help mysql sysadmin data-structures

  • MySQL syntax error near ''
    N nathionice

    Hi Thanks in advance for helping me. I have this mySQL query that fails i have no idea why i. Below is the code I left some space for readability $lines=file("somefile5640.001"); $headerTable=explodeX(Array(",","\n"),$lines[0]); $table ="HeaderRecord"; WriteArrayToHeaderDatabase($headerTable,$table); function WriteArrayToHeaderDatabase($headerTable,$table)//Pass which table am i writing to { //I do the connecting to database here which is fine the problem is below $query = "INSERT INTO ".$table."(FileIdentifier, Version, ReceiverIdentifier, Date, Time, FileGenerationNumber) VALUES"; for($i = 0, $c = count($headerTable); $i < $c; $i += 6) { // Add the next batch of values to the query string $query.= "('".$headerTable[$i]."','".$headerTable[$i+1]."','".$headerTable[$i+2]."','".$headerTable[$i+3]."','".$headerTable[$i+4]."','".$headerTable[$i+5]."')"; //$query .= "(".$headerTable[$i].",".$headerTable[$i+1].",".$headerTable[$i+2].",".$headerTable[$i+3].",".$headerTable[$i+4].",".$headerTable[$i+5].")"; echo "Query is failing"; // Add a comma is this is not the last batch if($i + 1 < $c) { //$query .= ""; $query .=","; } echo $query; $result = mysql_query($query); if (!$result) { die('Query failed: ' . mysql_error()); } } return true; // When i echo the query and run the code i get what shown below Query is failingINSERT INTO HeaderRecord(FileIdentifier, Version, ReceiverIdentifier, Date, Time, FileGenerationNumber) VALUES('SOF','1','1500','19970519','112904','1 '),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 '' at line 1

    Linux, Apache, MySQL, PHP database help mysql sysadmin data-structures

  • PHP File Open and Reading character by character
    N nathionice

    Posted Today, 12:07 AM Hi All Thanks in advance for the help, I have the PHP code below to read contents of the file. //The code does not work, it returns the output below " outputResource id #3 Quote Warning: Invalid argument supplied for foreach() in C:\XAMPP\htdocs\kampcoordinators\test.php on line 10"

    Linux, Apache, MySQL, PHP php help

  • imap_search problem
    N nathionice

    Could there problem be because I am using pop3 driver to access the emails. I am using the code below: $MAILSRV="mail.somewhere.com:110/pop3/notls"; $imap = imap_open ("{".$MAILSRV."}INBOX", "someemail@somewhere.com", "password");

    Linux, Apache, MySQL, PHP help data-structures

  • imap_search problem
    N nathionice

    Thanks for the help Niall. I tried yours as well it returned all the messages. In case you might have an idea, what possible server configuration could be causing this. Regards Nath

    Linux, Apache, MySQL, PHP help data-structures

  • imap_search problem
    N nathionice

    I am using the imap_search function to return an array of unseen messages but all the messages are returned. I only want to show unread messages but the code returns all the messages (numbers) in the mailbox. Thanks in advance for your help. Below is the code. $result = imap_search($imap,'UNSEEN'); foreach ($result as $value) { echo " the unseen message number is"; echo "
    "; echo $value; echo "
    "; }

    Linux, Apache, MySQL, PHP help data-structures
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups