473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PHP/SQL insert issue

Hi guys, please excuse me as im a bit of a noob. I'm making a blog site where the user can use a control panel page to update their blogs / articles. Its all going ok but when i post either " or ' into the text field it doesnt make it in to the data base.

Can anyone help? heres my code:


[PHP]<? session_start();
$_SESSION['text'] = $text;


//Functions!
$ip = $_SERVER['REMOTE_ADDR'];
{


{
$sqlquery = "INSERT INTO article (title, body, poster, link, cat) VALUES ('$title', '$body', '$poster', '$link', '$cat')";
} {
/* $sqlquery = ""; */
}

$results = mysql_query($sqlquery);

mysql_close();

print "<span class='p2'><br><br>Record Updated<br><br>";
print "Catagory = $cat<br><br>";
print "title = $title<br><br>";
print "Body = $body<br><br>";
print "Source = $link<br><br>";
print "Posted By = $poster<br><br>";

}
?>[/PHP]


And the html form

[HTML]<form action="addarticle_1.php" method="post">
<tr class="para">
<td colspan="2"><div align="center"> <strong>Welcome to Add an Article!</strong><br />
Please fill in the form below to add a new article.</div>
<span>
<hr align="center" size="1" />
</span></td>
</tr>
<tr class="para">
<td align="right">title : </td>
<td width="300" align="left"><input type="text" name="title" class="input" size="80" maxlength="80" value="<? echo $_SESSION['title']; ?>" />
</td>
</tr>
<tr class="para">
<td align="right">Info : </td>
<td align="left"><textarea name="body" input type="text" cols="100" rows="20" wrap="VIRTUAL" class="input" value=" <? echo $_SESSION['body']; ?> " /></textarea><br>
<b>Please note that images should be uploaded before writing your article.</b>
</td>
</tr>
<tr class="para">
<td align="right">Page : &nbsp; &nbsp; &nbsp; </td>
<td align="left"><br />
<input type="radio" name="cat" class="input" value="Hardware" />Hardware <br />
<input type="radio" name="cat" class="input" value="Gadgets" />Gadgets <br />
<input type="radio" name="cat" class="input" value="TV" />TV <br />
<input type="radio" name="cat" class="input" value="Software" />Software <br />
<input type="radio" name="cat" class="input" value="Apple" />Apple <br />
<tr class="para">
<td align="right">Article By : </td>
<td width="300" align="left"><input type="text" name="poster" class="input" size="80" maxlength="80" value="<? echo $_SESSION['poster']; ?>" />
</td>
</tr></td>
</td>
</tr>
<tr class="para">
<td align="right">Source : </td>
<td width="300" align="left"><input type="text" name="link" class="input" size="80" maxlength="80" value="<? echo $_SESSION['link']; ?>" /></td>
</tr>
<tr class="para">
<td colspan="2"><hr size="1" /></td>
</tr>
<tr class="para">
<td colspan="2" align="center"><input name="button" type="submit" class="buybutton" value="Submit article" /></td>
</tr>
</form></table>[/HTML]
Feb 2 '08 #1
2 1963
Markus
6,050 Expert 4TB
have a look at mysql_real_escape_string'ing your user input.

Or you could str_replace() the quotes.
Feb 2 '08 #2
have a look at mysql_real_escape_string'ing your user input.

Or you could str_replace() the quotes.
Hi Mark,

Sorry its taken me so long to reply, got it working in the end thanks to you!

Ta

Harry
Feb 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: php newbie | last post by:
Hello, I am trying to load a simple tab-delimited data file to SQL Server. I created a format file to go with it, since the data file differs from the destination table in number of columns. ...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
9
by: adi | last post by:
Hi all, Hope there is a quick fix for this: I am inserting data from one table to another on the same DB. The insert is pretty simple as in: insert into datatable(field1, field2, field3)...
6
by: harborboy76 | last post by:
Hi, I am trying to insert a large number of rows into a table inside a SPL. But every time, I run the SPL, the table is locked because of the INSERT. When I tried to issue a COMMIT, right after...
1
by: Christian Soltenborn | last post by:
Hi experts, I am working on a university project based on VB .NET. I have a connection to MS Access, and I want to insert some data into the database. The sql command INSERT INTO Shoe (Brand,...
10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
5
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
2
by: rosaagain | last post by:
I have a sql insert where I would like to add a bunch of fields from my form to one column in my db. Is this do-able? If so, any hints? My insert statement is : strSQL = "Insert into Ticket...
2
by: =?Utf-8?B?Y2F0?= | last post by:
We recently moved an older ASP.NET 1.1 code base on to ASP.NET 2.0, .NET 3.0 and Windows 2003 Server SP2. We started experiencing the following issue with the web cache (the code is straightforward...
4
by: LouiseR | last post by:
I just recently tried to use a multi-row insert on a table that contains a timestamp column, but I get SQLCODE -180 even though I'm positive that the value that I'm trying to insert is correct. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.