![]() |
Quick PHP / Mysql question
I am trying to insert the $array[14] result into my mysql database but it is just inserting $array[14] in plain text instead of the variable.
Code:
<?phputs\', \'"$arrays[14]"\', \' uts\', \'echo $arrays[14]\', \' uts\', \'".$arrays[14]."', \' and a few other variations but it just gave a http 500 error or inserted it in plain text. Incase your wondering about the weird insert command and all the unnecessary back slashes, I got the code from inserting manually into the mysql database and hitting create php code since nothing else was really working. |
try this
Code:
$query = 'INSERT INTO `sms`.`redirects` (`id`, `msg`, `from_num`, `to_num`, `from_country`, `to_country`, `status2`, `time_created`) VALUES (NULL, \'apples\', \'peanuts\', \'".$arrays[14]."\', \'\', \'\', \'\', \'\');'; |
You have to enclose an array in curly brackets.
\'{$array[14]}\' You should also use double quotes around the query, then you won't have to escape every single quote in the line. |
hmm both suggestions just insert the plain text into the to_num field
".$arrays[14]." and {$arrays[14]} I tried doing it with double quotes before but it kept screwing up so I am just copying it from the create php code option in phpmyadmin. http://img33.imageshack.us/img33/4757/sqlhelp.jpg |
boo ya ka cha
Code:
mysql_select_db($mysql); |
single and double quotes.... you're getting all mixed up and confused...
run this script and see for yourself where your problem lies.... Code:
<?php |
Yes single quotes means literal so if you have '.$string.' the out put will be .$string. With double quotes ".$string." the output would be whatever $string = to
|
Quote:
|
Quote:
|
Everyone who has replied to this thread writes code vulnerable to SQL injections - never hire anyone from this thread.
|
| All times are GMT -7. The time now is 05:54 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123