-
Posts
58 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by Stream
-
The error Last inserted record has id 0 happens when i am putting $sql = mysql_query("SELECT id_add_car,model,date FROM add_new_car WHERE model='$model' and date=NOW() ORDER BY id_add_car,date DESC LIMIT 1");$maxrowid = mysql_fetch_array($sql);$id_insert = $maxrowid['id_add_car']; echo "<br /><br /><h2><b>".$id_insert."</b></h2><br /><br />";
-
What if it gives me an error like Last inserted record has id 0$sql = mysql_query("SELECT id_add_car,model,date FROM add_new_car WHERE model='$model' and date=NOW() ORDER BY id_add_car,date DESC LIMIT 1");$maxrowid = mysql_fetch_array($sql);$id_insert = $maxrowid['id_add_car']; echo "<br /><br /><h2><b>".$id_insert."</b></h2><br /><br />";$sql ="Insert into image_add_car (user_id,ap_id,big,small) VALUES (LAST_INSERT_ID(),'2','$filename','$filename1')"; printf ("Last inserted record has id %d\n", mysql_insert_id()); mysql_query($sql) or die(mysql_error());
-
Can you tell me please why when I am trying to get the ID by the way like it's shows me nothing $sql = mysql_query("SELECT id_add_car,model,date FROM add_new_car WHERE model='$model' and date=NOW() ORDER BY id_add_car,date DESC LIMIT 1");$maxrowid = mysql_fetch_array($sql);$id_insert = $maxrowid['id_add_car']; echo "<br /><br /><h2><b>".$id_insert."</b></h2><br /><br />";
-
Thank you so much I will check it now
-
$sql = "Insert into image_add_car (user_id,ap_id,big,small) VALUES ((SELECT id_add_car FROM add_new_car WHERE date=NOW() ORDER BY id_add_car,date DESC LIMIT 1),'2','$filename','$filename1')";mysql_query($sql); I ve done it as you told me but it gives the same thing. to Mudsaf It gives no erros
-
Thanks for people who create this site because i could get lat's of help here ! But recently met a new problem with insert and select which doesn't work for meThe query looks like this $sql = "Insert into image_add_car (user_id,ap_id,big,small) VALUES ('SELECT id_add_car FROM add_new_car WHERE date=NOW() ORDER BY id_add_car,date DESC LIMIT 1','2','$filename','$filename1')";mysql_query($sql); but insted of id from id_add_car in the field of user_id i can see just 'SELECT id_add_car FROM add_new_car WHERE date=NOW() ORDER BY id_add_car,date DESC LIMIT 1'
-
I think i should change it if (($pos!==false) || ($posnum!==false)){ $change = str_replace($numbers, "", $phrase);$changenum = str_replace($numbers, "",$phrasenum);} to this one if (($pos!==false) || ($posnum!==false)){ $change = str_replace($numbers, "", $phrase); $changenum = str_replace($numbers, "",$phrasenum); Else$change = "";$changenum ="";}
-
<?php$file=fopen("test2.txt","r");$numbers = array("RESOURCE: ","PARAMETERS:", "CPS ","( 1)","STATE: EQ ","( 0) STATE: NE","( 2) ","M'35611",",","M","'");//$words = array("", "", "");while (!feof($file)){$phrase = fgets($file);$phrasenum = fgets($file);$pos = strpos($phrase, "RESOURCE:");$posnum = strpos($phrasenum , "M'35611");if (($pos!==false) || ($posnum!==false)){ $change = str_replace($numbers, "", $phrase);$changenum = str_replace($numbers, "",$phrasenum);} Echo $change . $changenum ."<br>";}fclose($file);?> File look's like this (about 2000) : RESOURCE: CPS DSL 1- 8080 ( 1) STATE: DSL PARAMETERS:M'35611523535 , , M' , GGGHJ 89098 HU (1) State HJUK 18292 (this string I should escape)GGGHJ 45441 HU (1) Lertd HJUK 157346 (this string I should escape)RESOURCE: CPS DSL 1- 8081 ( 1) STATE: DSLPARAMETERS:M'35611472097 , , M' , GGGHJ 89098 HU (1) State HJUK 18292 (this string I should escape)GGGHJ 45441 HU (1) Lertd HJUK 157346 (this string I should escape)RESOURCE: CPS DSL 1- 8082 ( 1) STATE: DSLPARAMETERS:M'35611928613 , , M' , GGGHJ 89098 HU (1) State HJUK 18292 (this string I should escape)GGGHJ 45441 HU (1) Lertd HJUK 157346 (this string I should escape)RESOURCE: CPS DSL 1- 8083 ( 1) STATE: DSLPARAMETERS:M'35611928296 , , M' , Thanks a lot
-
but this way it prints 6 times the same date in the string of " RESOURCE: CPS DSL 1- 8080 ( 1) STATE: DSL " 6 times and just then goes to the other string and again for 6 times of "RESOURCE:" or "M'35611".
-
do you mean i should do some thing like this while (!feof($file)){$phrase = fgets($file);$phrasenum = fgets($file);// $pos = (strpos($phrase, "RESOURCE:") and $posnum = strpos($phrasenum , "M'67832"));$pos = strpos($phrase, "RESOURCE:");$posnum = strpos($phrasenum , "M'67832");if (($pos!==false) || ($posnum!==false)){ $change = str_replace($numbers, "", $phrase);$changenum = str_replace($numbers, "",$phrasenum);} Echo $change . $changenum ."<br>";
-
I am trying to see if there is in the string "RESOURCE:" and "M'35611" the code should do replace ("RESOURCE: CPS" DSL 1- 8080 "( 1) STATE: DSL" and echo "DSL 1- 8080") && ("M'35611"523535 " , , M' ," and echo 523535) else it should bypass the string.
-
I could get something like bellow which gets the date I need but there is something goes wrong it's echos the date which I am trying to exclude using if statment. Am I incorrect in building If statment <?php$file=fopen("test2.txt","r");$numbers = array("RESOURCE: ","PARAMETERS:", "DSL ","( 1)","STATE: SL ","( 0) STATE: VT","( 2) ","[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif][size=3]M'35611[/size][/font][/color]",",","K","'");//$words = array("", "", "");while (!feof($file)){$phrase = fgets($file);$phrasenum = fgets($file); $pos = strpos($phrase, "RESOURCE:") && $posnum = strpos($phrasenum , "M'35611");if (($pos!==false) || ($posnum!==false)){ $change = str_replace($numbers, "", $phrase);$changenum = str_replace($numbers, "",$phrasenum);} Echo $change . $changenum ."<br>"; }fclose($file);?> Thanks in advance
-
I built an array with what I need to remove and then using str_replace I remove it but I'd like to use IF statement like bellowif (!strpbrk($phrase, "RESOURCE:"));here should be something like if just the string has "RESOURCE:" or M'3561should be done str_replace and echo it.But it does't work. $file=fopen("test2.txt","r");$numbers = array("RESOURCE: ", "CPS ", "( 1)","STATE: EQ ", "PARAMETERS",":","M'3561",", ","K'","( 0) STATE NE ","READ REPORT","0710138"," 29 ","0029"," 03-03-19"," 1745");//$words = array("", "", "");while (!feof($file)){// $phrase = "RESOURCE: CPS DSL 1- 8080 ";$phrase = fgets($file);if (!strpbrk($phrase, "RESOURCE:"));{here should be something like if just the string has "RESOURCE:" or M'3561should be done str_replace and echo it$change = str_replace($numbers, "$words", $phrase);}Echo $change ."<br>";}echo count($phrase);fclose($file); Could you help me please to solve the problemThanks in advance
-
Could you help me please to realize it using While or Foreach wich will scan whole the file.
-
thanks for recomended tutorialbellow I'd like to show what i needRESOURCE: CPS DSL 1- 8080 ( 1) STATE: DSL PARAMETERS:M'35611523535 , , M' ,RESOURCE: CPS DSL 1- 6478 ( 1) STATE: DSL PARAMETERS:M'33333333333 , , M' ,RESOURCE: CPS DSL 1- 8036 ( 1) STATE: DSL PARAMETERS:M'35611523400 , , M' , For me its enough to get date after CPS for example:DSL 1- 8036DSL 1- 8080DSL 1- 8036 Yes ! And http://www.php.net/m...tion.substr.php exactly what i need I think i should build something like this <?php$filename = 'test.txt';$fp = fopen($filename, 'w'); Here I think i should create some thing like this for i= 0 to count (ammount of string) echo substr('abcdef', 1, 3); // bcd in my case echo substr('M'35611523400', 6, 7); // 523400 echo to table or excel = DSL 1- 8080echo to table or excel = 523400 fclose($fp);?>
-
RESOURCE: CPS DSL 1- 8080 ( 1) STATE: DSL PARAMETERS:M'35611523535 , , M' , From this part RESOURCE: CPS DSL 1- 8080 ( 1) STATE: DSL I should get (DSL 1- 8080)From this part M'35611523535 , , M' , (523535 meaning the last seven number)
-
I've got a file like bellow (the date might be about 5000) RESOURCE: CPS DSL 1- 8080 ( 1) STATE: DSL PARAMETERS:M'35611523535 , , M' , GGGHJ 89098 HU (1) State HJUK 18292 (this string I should escape)GGGHJ 45441 HU (1) Lertd HJUK 157346 (this string I should escape) RESOURCE: CPS DSL 1- 8080 ( 1) STATE: DSLPARAMETERS:M'35611472097 , , M' , and I should get some date from it like here: DSL -----------number1- 8080 523535 (I should get it from M'35611523535) and then echo it to table or exel file. <?php$filename = 'test.txt';$fp = fopen($filename, 'w'); Here I think i should create some thing like this for i= 0 to count (ammount of string) echo to table fclose($fp);?> Thanks in advance
-
I appreciate for help I could get it work. The path goes to db and the I can veiw it. But also I'd like by the way thambnail the images and locate path the same way .image1 image2 image3 image4 image5 image6 image_small1 image_small2 image_small3 image_small4 image_small5 image_small6 I've got the thambnail script which I would like to implement hereCould you please help me do it $i = 1;$sm = 1;$images_sm = "thumbnails_"$uploadFilename[$key];// now let's move the file to its final and allocate it with the new filenameforeach($active_keys as $key){@move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key],$uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); $cols[] = "image" . $i++; //<-- note that I removed the comma $cols_sm[] = "image_small" . $sm++; $data[] = "'" . basename($uploadFilename[$key]) . "'"; //----------------------------------------------------------------------------------------------------- $width=100; //*** Fix Width & Heigh (Autu caculate) ***// //$size=GetimageSize($images); $size=GetimageSize($uploadFilename[$key]); $height=round($width*$size[1]/$size[0]); $images_orig = ImageCreateFromJPEG($uploadFilename[$key]); $photoX = ImagesX($images_orig); // Widht $photoY = ImagesY($images_orig); // Hight $images_fin = ImageCreateTrueColor($width, $height); ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY); ImageJPEG($images_fin,"uploaded_files/".$images_sm); ImageDestroy($images_orig); ImageDestroy($images_fin); // -------------------------------------------------------------------------------------------------------------- $data_sm[] = "'" . basename($uploadFilename[$key]) . "'"; }$query = 'INSERT INTO `imloop` (' . implode(', ', $cols) . ' , ' . implode(', ', $cols_sm) . ') VALUES (' . implode(', ', $data) . ' , ' . implode(', ', $data_sm) . ')';
-
I have tested it and it locate image (to db) as I needed but the problem is now shown bellow : $i = 1;$cols = array();$data = array();// now let's move the file to its final and allocate it with the new filenameforeach($active_keys as $key){@move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); $cols[] = "image" . $i++; $data[] = basename($uploadFilename[$key]);} $cols = array_map ('mysql_real_escape_string', $cols);$data= array_map ('mysql_real_escape_string', $data); $query = 'INSERT INTO `imloop` (' . implode(', ', $cols) . ') VALUES ("' . implode('", "', $data) . '")'; mysql_query($query) or exit($query . '<br />' . mysql_error()); INSERT INTO `imloop` (`id`, `image1`, `image2`, `image3`, `image4`, `image5`, `image6`) VALUES(1, '1352903903-1.jpg', 1352903903, 1352903903, 1352903903, 1352903903, 1352903903); or INSERT INTO `imloop` (`id`, `image1`, `image2`, `image3`, `image4`, `image5`, `image6`) VALUES(1, '1352903903-1.jpg', 1352903903, 1352903903, 1352903903, 1352903903, 1352903903), // here I tried to upload 6 different images(2, '1352904073-6.jpg', 1352904073, 0, 0, 0, 0), // here I tried to upload 2 different images(3, '1352904279-1.jpg', 1352904279, 1352904279, 0, 0, 0), // here I tried to upload 3 different images(4, '1352904587-1.jpg', 1352904587, 1352904587, 0, 0, 0); why it locate just first image I am putting in and repeat it to the `image2`, `image3`, `image4`, `image5`, `image6` .and doesn't show others I am adding.
-
foreach($active_keys as $key){@move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); $query_part_1 .= " image" . $i++ . ",";$query_part_2 .= " '" . $uploadFilename[$key]. "',"; } $cols[] = $query_part_1;$data[] = $query_part_2; $cols = array_map ('mysql_real_escape_string', $cols);$data= array_map ('mysql_real_escape_string', $data);$query = 'INSERT INTO `imloop` (' . implode(',', $cols) . ') VALUES ("' . implode('","', $data) . '")';mysql_query($query) or exit($query . '<br />' . mysql_error()); mysql_close($connection); I've puted out a part of code and could get some result INSERT INTO `imloop` ( image, image1, image2, image3, image4, image5,) VALUES (" \'Z:/home/multiple/www/uploaded_files/1352319971-1.jpg\', \'Z:/home/multiple/www/uploaded_files/1352319971-2.jpg\', \'Z:/home/multiple/www/uploaded_files/1352319971-3.jpg\', \'Z:/home/multiple/www/uploaded_files/1352319971-5.jpg\', \'Z:/home/multiple/www/uploaded_files/1352319971-6.jpg\', \'Z:/home/multiple/www/uploaded_files/1352319971-5.jpg\',")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 ') VALUES (" \'Z:/home/multiple/www/uploaded_files/1352319971-1.jpg\', \'Z:/home/' at line 1 I think i should find a way to escape comma (image5,) and also VALUES (" \' Could you help me solve it please
-
I am planing to have about 10 (imag1,image2,image3,image4,image5,imag6........image10)
-
I have chaned the code like bellow but it gives me an error foreach($active_keys as $key){@move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); $cols[] = $query_part_1; $data[] = $query_part_2; $query_part_1 .= " image" . $i++ . ",";$query_part_2 .= " '" . $uploadFilename[$key]. "',"; $cols = array_map ('mysql_real_escape_string', $cols); $data= array_map ('mysql_real_escape_string', $data); $query = 'INSERT INTO `imloop` (' . implode(',', $cols) . ') VALUES ("' . implode('","', $cols) . '")'; } mysql_query($query) or exit($query . '<br />' . mysql_error()); mysql_close($connection); INSERT INTO `imloop` (, image,, image, image1,, image, image1, image2,, image, image1, image2, image3,, image, image1, image2, image3, image4,) VALUES (""," image,"," image, image1,"," image, image1, image2,"," image, image1, image2, image3,"," image, image1, image2, image3, image4,")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 ' image,, image, image1,, image, image1, image2,, image, image1, image2, image3,,' at line 1
-
foreach($active_keys as $key){@move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); $query_part_1 = '';$query_part_2 = '';$i = 1; // add the comma AFTER you write the key/values to the strings$query_part_1 .= " image" . $i++ . ",";$query_part_2 .= " '" . $uploadFilename[$key]. "',"; } I have taken out this part of script but that doesn't give any result ! In this case it just put one path. $query_part_1 = preg_replace("/,$/","",$query_part_1); // remove the comma at the end of the string$query_part_2 = preg_replace("/,$/","",$query_part_2);$query = "INSERT INTO `imloop` (" .$query_part_1. ") VALUES (" .$query_part_2. ")"; mysql_query($query) or exit($query . '<br />' . mysql_error());mysql_close($connection);
-
foreach($active_keys as $key){@move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); $query_part_1 = '';$query_part_2 = '';$i = 1; // add the comma AFTER you write the key/values to the strings$query_part_1 .= " image" . $i++ . ",";$query_part_2 .= " '" . $uploadFilename[$key]. "',"; $query_part_1 = preg_replace("/,$/","",$query_part_1); // remove the comma at the end of the string$query_part_2 = preg_replace("/,$/","",$query_part_2);$query = "INSERT INTO `imloop` (" .$query_part_1. ") VALUES (" .$query_part_2. ")"; mysql_query($query) or exit($query . '<br />' . mysql_error()); } mysql_close($connection); The code above gives something like below id image1 image2 image3 image4 image5 image6 1 pic12 pic23 pic2 Something like this but I need to get something like this id image1 image2 image3 image4 image5 image6 1 pic1 pic2 pic3 pic4 pic5 pic62 Could you help me please create something like this.
-
At last could find what i looked for ! <?php# Assuming image1, etc accept null values you could try something like this... Not tested#set some variables$query_part_1 = '';$query_part_2 = '';$i = 1;foreach($active_keys as $key){ $query_part_1 .= ",'image" . $i++ . "'"; $query_part_2 .= ",'" . $_FILES[$fieldname]['name'][$key] . "'";}$query = "INSERT INTO properties ('location','description'" . $query_part_1 . ") VALUES ('" . $location . "','" . $description . "'" . $query_part_2 . ")";?>