![]() |
PHP and MYSQL insert question
I have the following modem response being inserted into a field on a mysql database:
This is the complete contents of the field: Code:
AT+SSS="SHOW"FIELD NAMES = CT, STATUS, FROM, TIME, MESSAGE EXAMPLE FIELD INSERTIONS 0, OK, +974941949, 09/12/15,03:06:18+00, Sup 1, OK, +974941949, 09/12/15,14:26:36+00, Yo Anyone know how or where I can find out how to do this? Seems pretty simple if I only knew a bit more php :( |
Well, assuming you know how to split the fields up and know your mysql insert statement?
You would use the mysql_query function with your mysql statement. http://us3.php.net/manual/en/function.mysql-connect.php http://us3.php.net/manual/en/function.mysql-query.php http://us3.php.net/manual/en/function.mysql-close.php Jimmy |
What are you trying to do???
Do you need to parse the output first or do you just want to build the SLQ insert funtion into the page. |
I just learned over the last hour how to split the fields. Now I have array [0] to array [19] outputted with the following script:
Code:
print_r (explode(",\"",$str));Code:
print_r (explode(",\"",$str)); |
Quote:
field1 field2 field3 field4 field5 hello my name is fred Think i figured out the php explode / split thing, just need to get the correct results back in the database now. |
loop through the array elements
|
Oh, I see. You will get it...this is where we all start with php. You should look at W3schools or tiztag for tutorials.
I wrote something real quick for your AT commands but not sure how exactly it would work for you. But should give you some Idea Code:
<?php |
Quote:
|
hmm i got this to separate the thing into 15 arrays, 5 per message,
Code:
<?phpCode:
$sql = "INSERT INTO modem2 ('zero','one','two','three','four','five') VALUES (".$new[0].",".$new[1].",".$new[2].",".$new[3].",".$new[4].","$new[5].")"; |
I think I got all the arrays declared properly, just need to know the insert command
|
Code:
<?php |
Don't forget the ID key value for the tables next increment...if tour db reads
1 ok name number from to message 2 ok name number from to message 3 ok name number from to message ... 88 ok name number from to message 89 ok name number from to message then the next input would fill automatically. INSERT INTO modem2 ('id','zero','one') VALUES ('DELETETHIS', ".$new[0].",".$new[1].")"; see how the first value is blank, it would automatically populate id's next entry 90 ok name number from to message 91 ok name number from to message |
Quote:
"I need Google recreated, you're pretty good, should be simple and easy for you, how long you think it will take? 10 mins?" Makes me :1orglaugh:1orglaugh:1orglaugh * PS: this wasn't directed at you, I just hear that sentence all the time. |
Quote:
|
Quote:
hmm still having problems. how do I just echo a certain array. I got it to output: Code:
Array ( [0] => 0 [1] => OK" [2] => +974941949", [3] => 09/12/15,03:06:18+00echo $array(2); echo $array[2]; $array[2] = $hello; echo $hello; etc, just cant seem to figure it out |
echo $array[2];
|
Quote:
Replace $arrays with $arrays[3] Code:
$contents = file_get_contents("at.php"); |
Quote:
|
Quote:
|
Quote:
|
Dude if you want a free text messaging solution, I have one for you...
http://mobiquio.com/playsms login:demo and pass:password |
I tried with the 'S" and it still won't print the result :(
Code:
<?php |
Quote:
|
might have got it, trying it out now :)
|
Yup got it! Just changed to:
$arrays = (explode(",\"",$str)); $arrays = (explode("\"",$str)); Thanks a bunch everyone |
Man, this thread should have been over in like 1-2 replies. Talk about your basic basic programming function, It's so sad it took 25.
I guess that's what you get on a webmaster board. :( |
Quote:
|
hey bird, do you have icq? might have some paid work for you :)
|
Quote:
|
| All times are GMT -7. The time now is 05:04 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123