Hey there If some person could help me with this i would be eternely thankfull. what i need help with is. let's say i have this form that's shown bellow, and i when a user inserts their cell number in the field and presses the button, i want it to search trou the database named "mms" and the table "numbers" and search for their number on the row ['sender'] for the number enterd, then if a number is found search the row ['id'] use that it and check if a .jph file in /data/ folder has the same name as that id, and if it exist, display the picture or pictures on the page (if they sent in several) from that number with a link to each picture HTML: <form name="input" action="html_form_action.php" method="get"> Cell numbet: <input type="text" name="user"> <input type="submit" value="Search"> </form> Code (markup): I know how to make the PHP script get the cell number, but i have no idea on the rest my eye started to bleed. so if someone could help me i would love you for life.
I don't get what you mean, Could you make it a bit clearer and then I may be able to help. Do you know how to connect to a mysql database.. maybe you should look it up if you don't.
ye i know, but the problem is how to put it all toegther and making it work anyhow i wil ltry to explain Basiclly, i have a page where where i send in my MMS message from my cellphone, when intercepted by my script it's enterd into the database in the table "MMS" on the Row "ID" and given and uniqe Id number, then the picture is save with that ID name into the folder /data/ and my cellnumber is enterd on the row "sender" in the same database. now what i want is a script form that i cant enter my cellnumber into, press "search" and it searcher the database for "my number" or number (if i sent in more then 1 times" and displays all the images that i have send in with link's to then example [Picture shown here] [Link to the picture shown under it] i hope this made more sense
got as far as check jph file, then got confused, where is the images, what in these jph files ??? <? $theform = <<<END <form name="input" action="" method="post"> Cell number: <input type="text" name="number"> <input type="submit" value="Search"> </form> END; if( !($con = mysql_connect( MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD )) ) : die("Cannot connect to mysql"); elseif( !mysql_select_db( MYSQL_DATABASE ) ): die("Cannot select database"); else: if( $_POST ): $number = mysql_real_escape_string( stripslashes( trim( $_POST['number'] )), $con ); $result = mysql_query("SELECT * FROM `numbers` WHERE sender = '$number'", $con ); if( !$result ): die("Cannot query server"); elseif( !mysql_num_rows( $result ) ): die("No records found"); else: while( $assoc = mysql_fetch_assoc( $result ) ): print_r( $assoc ); endwhile; endif; else: echo $theform; endif; endif; ?> PHP: that'll get you started prolly .....
show me the output of the code I posted, if youre quick enough I'll be able to finish before being too drunk for the night .....
what i got, Parse error: parse error, unexpected T_ELSE in C:\Sites\Single8\lunarplejs\webroot\mms\test2.php on line 23 btw im just looking at thecode... did you asume the row "numbers" was in the databse ? cause the row "numbers" it's in the table "mms" wich is in the database, just if you missed it
oh sorry, do this before the script I posted minute ago, then gimme some output again. <? define("MYSQL_SERVER", "localhost"); define("MYSQL_PASSWORD", "password"); ?> etc
still gettgin Parse error: parse error, unexpected T_ELSE in C:\Sites\Single8\lunarplejs\webroot\mms\test2.php on line 23 dunno if you saw that i edited my post but i think i was to late!
I'll level with you, I'm too drunk for this sorta stuff now, it's taken me a fair amount of time to find this thread, but I have asked another dp php guru to come along and have a look, I'm sure he will and I'm sure he'll have as good or a better answer than me, just sit tite.....
I didn't read through all the thread, I just modified Joe's code slightly. See if it works for you. <?php $theform = <<<END <form name="input" action="" method="post"> Cell number: <input type="text" name="number"> <input type="submit" value="Search"> </form> END; define("MYSQL_SERVER", "localhost"); define("MYSQL_USERNAME", "root"); define("MYSQL_PASSWORD", "password"); define("MYSQL_DATABASE", "database name"); $con = mysql_connect( MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD ) OR die("Cannot connect to mysql"); mysql_select_db( MYSQL_DATABASE ) OR die("Cannot select database"); if( $_POST ) { $number = mysql_real_escape_string( stripslashes( trim( $_POST['number'] )), $con ); $result = mysql_query("SELECT * FROM `numbers` WHERE sender = '$number'", $con ) OR die("Cannot query server"); if( !mysql_num_rows( $result ) ) { die("No records found"); } else { while( $assoc = mysql_fetch_assoc( $result ) ) { print_r( $assoc ); } } } else { echo $theform; } ?> PHP:
Now the form works but when i search for a number i get "Cannot query server" as i said erlier to joe, btw im just looking at thecode... did you asume the row "numbers" was in the databse main ? cause the row "numbers" it's in the table "mms" wich is in the database, just if you missed it
ok help us out, post the code that inserts into the database in the first place, I really should not be here, I'll prolly make it worse .... nico come back .....
here is the code that put's it all in the database and save the image <?php require_once('decode/mimeDecode.php'); $MYSQL_HOST = 'AAA'; $MYSQL_USER = 'AAA'; $MYSQL_PASSWORD = 'AAA'; $MYSQL_DATABASE = 'AAA'; error_reporting(0); mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD); mysql_select_db($MYSQL_DATABASE); if($_SERVER['REQUEST_METHOD'] == 'POST') { $mms = new MMSDecoder(); //debug only //echo "<hr/><pre>".print_r($mms, true)."</pre><hr/>"; $message = mysql_real_escape_string($mms->subject); $phonenr = mysql_real_escape_string($mms->number); $tariff = isset($_POST['tariff']) ? (int)$_POST['tariff'] : 0; foreach ($mms->parts as $part) { if ($part['type'] == 'image/jpeg'){ $sql = "INSERT INTO mms (sender,message,tariff,tstamp) VALUES ('%s','%s',%d,NOW())"; $sql = sprintf($sql,$phonenr,$message,$tariff); // execute $res = mysql_query($sql) or die(mysql_error()); // save image in /data/ $filename = 'data/'.mysql_insert_id().'.jpeg'; file_put_contents($filename,$part['body']); } else { //do nothing } //close internal if } //close foreach } //close master If //////////////////////////////////////////////////////////////// class MMSDecoder { var $subject; var $number; var $parts; function MMSDecoder() { $this->subject = $_SERVER['HTTP_MOSMS_SUBJECT']; $this->number = $_SERVER['HTTP_MOSMS_NUMBER']; $mimedata = file_get_contents('php://input'); $headers = "Content-Type: {$_SERVER['CONTENT_TYPE']}\n"; $headers .= "Content-Length: {$_SERVER['CONTENT_LENGTH']}\n"; $params = array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers'=> true); $decoder = new Mail_mimeDecode($headers . "\n" . $mimedata); $decoded = $decoder->decode($params); foreach($decoded->parts as $part) { $temp = array(); $temp['type'] = $part->ctype_primary. '/' . $part->ctype_secondary; if(isset($part->headers['content-id'])) { $temp['cid'] = trim($part->headers['content-id'],'<>'); } if (isset($part->d_parameters['filename'])) { $temp['filename'] = $part->d_parameters['filename']; } $temp['body'] = $part->body; $this->parts[] = $temp; } } } ?> Code (markup):
I'm here, lol. Try changing this: $result = mysql_query("SELECT * FROM `numbers` WHERE sender = '$number'", $con ) OR die("Cannot query server"); PHP: To this: $result = mysql_query("SELECT * FROM `mms` WHERE sender = '$number'", $con ) OR die("Cannot query server"); PHP: (Basically just changing "numbers" to "mms")
now im getting loads on answers like Array ( [id] => 30 [sender] => 0701234567 [message] => bildmms test2 [tariff] => 0 [tstamp] => 2007-03-29 20:52:55 ) Array ( [id] => 31 [sender] => 0701234567 [message] => bildmms test2 [tariff] => 0 [tstamp] => 2007-03-29 20:52:55 ) Array ( [id] => 32 [sender] => 0701234567 [message] => bildmms test2 [tariff] => 0 [tstamp] => 2007-03-29 20:52:55 ) dont worry about the cell number. it's from a simulation so it's not real. here is the ID number of the picture that was save in /data ([id] => 31) so far thank you very very much! but if you can take it to help for a bit more, i would love you! what was needed from the benning as you didint read nico, when i search for a number like that it should only post back to me tbe Picture or pictures that that i sent in from that cell number, so basilly take that id/id's above and search the /data folder if the images are in there and display them on the resault page!
Joe just used the print_r() so you could see what content you get from the rows. It was more of an example. To achieve what you're trying to do, try replacing this loop: while( $assoc = mysql_fetch_assoc( $result ) ) { print_r( $assoc ); } PHP: With this. while( $assoc = mysql_fetch_assoc( $result ) ) { echo '<img src="data/'. $assoc['id'] .'.jpeg" /><br />' . "\n"; } PHP: Where you see the echo, the data between the single quotes is HTML. You can modify it for your needs.
cheers to you! thank you both very very much for the help! now i understand there is one lastthinkg, currently the pictures are displayed on each other, like Pic1 Pic2 Pic3 how can i insteed make it be displayed like Pic1 Pic2 Pic3 with a maximum of 6 pictures per row ?