Hi, can anyone please help me why I got this error every I uploaded files.
Error:
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in c:\Inetpub\wwwroot\uploadingfiles\add_file.php on line 89
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in c:\Inetpub\wwwroot\uploadingfiles\add_file.php on line 90
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in c:\Inetpub\wwwroot\uploadingfiles\add_file.php on line 92
Here is the code on the said warning message: - # Gather all required data
-
$name = mysql_real_escape_string($dbLink, $_FILES['uploaded_file']['name']);
-
$mime = mysql_real_escape_string($dbLink, $_FILES['uploaded_file']['type']);
-
$size = $_FILES['uploaded_file']['size'];
-
$data = mysql_real_escape_string($dbLink, file_get_contents($_FILES['uploaded_file']['tmp_name']));
And because of that error the name and mime of the files I uploaded didn't appear, thats why I cannot properly download the files. Maybe because the mime/filetype is not present.
Your help will be highly appreciated.
Thanks guys..
7 5100 Atli 5,058
Expert 4TB @roseple
Hi.
Did you swap back to the old mysql extension, or did you just forget the "i" in the function name?
The old mysql_real_escape_string function expects the first parameter to be a string and the second one to be the mysql connection resource.
Your code has it backwards.
The improved mysqli_real_escaped_string function (note the "i" in the function name) expects the first parameter to be a mysqli object, and the second one to be a string.
Your code has the parameters right, but leaves out the "i" in the function name.
Hi, I'm sorry I have another question..
Can anyone know why this warning message occur:
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in c:\Inetpub\wwwroot\uploadingfiles\add_file.php on line 89
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in c:\Inetpub\wwwroot\uploadingfiles\add_file.php on line 90
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in c:\Inetpub\wwwroot\uploadingfiles\add_file.php on line 92
Here's the code on the said line. - $name = mysql_real_escape_string($dbLink, $_FILES['uploaded_file']['name']);
-
$mime = mysql_real_escape_string($dbLink, $_FILES['uploaded_file']['type']);
-
$size = $_FILES['uploaded_file']['size'];
-
$data = mysql_real_escape_string($dbLink, file_get_contents($_FILES['uploaded_file']['tmp_name']));
And because of that warning messae the name, mime and filedata is not present that's why I cannot properly download the files I uploaded.
Thank you very much in advance.
@roseple
because you defined the parameters in the wrong order. as stated in the manual, the string comes first and the resource comes second.
Can you tell me how can I do that..
Thanks
@roseple
do what? you mean to correct the error?
Yup, if you don't mind..
Thank you very much..
Atli 5,058
Expert 4TB
You have the parameters of the function in reverse order.
One would think the solution would be obvious...
The database link is supposed to go after the data.
(Or not at all. That would work to.)
Keep in mind that the example code in my article is meant for a different function, as I explained in my first post in this thread.
Take a look at the examples in the links both myself and Dormilich posted. See how the parameters are used there.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: leegold2 |
last post by:
When I look directly in my db field I see a difference between these two
functions. The top line (seebelow) was inserted with addslashes vs. the
bottom line where I used mysql_real_escape_string....
|
by: Marcus |
last post by:
Hello,
My php.ini file currently has magic quotes set to On, but I have read
that it is better to code with it off.
Currently with magic quotes on, I only use stripslashes() to properly...
|
by: frizzle |
last post by:
Hi groupies,
I have 2 small questions, which i really want to be sure about:
- does mysql_real_escape_string() prevent any kind of mysq-injection?
- can it put escaped quotes etc in the DB, or...
|
by: Sam Martin |
last post by:
from a resource file.
Hi all,
Im having a bit of a moment.
I've got resource files in each of my assemblies, just named like
"Labels.resources" for example.
I've got a commond base...
|
by: |
last post by:
I'm picking up an 'IMPORTS' error for a simple database insert based on two
input entry boxes in my form?
It says an 'Imports' statement must preceede any declarations....... is this
perahps the...
|
by: comp.lang.php |
last post by:
when trying to use the mysql_real_escape_string() function, the
following warning occurs:
First of all, the user is not 'web' trying to connect to the database,
secondly, what is...
|
by: JM Ivler |
last post by:
Is there really any time when I don't want to run every _POST and _GET
through mysql_real_escape_string() before I use that data in accessing
the database?
In other words, is there a good reason...
|
by: zach |
last post by:
I created a comment form which will inserts the comments into a database
and displays them immediately. I want to make sure that its safe from
users inserting unwanted data into the database or...
|
by: ndlarsen |
last post by:
Hello.
It's been a while since I used php. Since then magic quotes has been
deprecated and will be removed when php 6.0 hits. My question is, what
should I be using when submitting data to a...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| | |