473,386 Members | 2,078 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,386 software developers and data experts.

Error in mysql_fetch_assoc()

I am trying to get the following code to work, and I am having some problems:

The code goes for actually 110 lines, but I have dismissed what is not needed.
The connection and all that works for another table with the database, and what is used to fetch the information is used elsewhere in the script. Its only when I add row "82" (number 16 here) it produces the error. It will not extract any of the information, and it wont update any of the information, because the primary key (the date) that is extracted from the fetch_assoc on line 82 is used elsewhere to update the sales number for that date.

It returns "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\setlastpurchase.php on line 82" when I try and run the script. The script is to take a date that is within a mysql table and added one to the sales for that date, because that information will be used for marketing purposes. I am trying to get it to extract the number of sales for the date of the "call" or ticket. It takes the total number of sales, and adds one to that so that it will continuously give us a number of how many sales for a particular date. If anyone could help me resolve this issue, it would be much appreciated.

btw the structure of the "marketing" table is as follows:
`Month` int(2) NOT NULL,
`Day` int(2) NOT NULL,
`Year` int(4) NOT NULL,
`Sales` int(10) NOT NULL,
`Date` datetime NOT NULL,
PRIMARY KEY (`Date`)

[PHP]
<?php
$cfg['mysql_server'] = 'localhost';
$cfg['database'] = 'mailinglist';
$cfg['user'] = 'root';
$cfg['passwordbase'] = '';
$db = @mysql_connect($cfg['mysql_server'], $cfg['user'], $cfg['passwordbase']);
//////////////includied to show where $calldate is from////////////////
while ($query = "SELECT * FROM `mailinglist`.`calls` WHERE `processed` = 0")
{
$result = @mysql_query($query, $db);
$row = mysql_fetch_assoc($result);
$calldate = $row["Date"];
$callday = dateconvert($calldate, 4);
$callmonth = dateconvert($calldate, 3);
$callyear = dateconvert($calldate, 2);
/////////////////////////////////////////////////////////////////////
$result8 = @mysql_query("SELECT * FROM 'mailintlist'.`marketing` WHERE `Date` = '$calldate' LIMIT 0, 1", $db);
//Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\setlastpurchase.php on line 82 (next line)//
$row8 = mysql_fetch_assoc($result8);
$oldsalesmarketing = $row8["Sales"];
$marketingdate = $row8["Date"];
if (!$marketingdate)
{// Run query
mysql_query("INSERT INTO `marketing`(`Date`, 'Month', 'Day', 'Year', 'Sales') VALUES('$calldate', '$callmonth', '$callday', '$callyear', '1')", $db);
echo "<br>WAS Empty";
$newsalesmarketing = 1;
}
else
{
echo "<br>Not Empty";
$newsalesmarketing = $oldsalesmarketing + 5;
$query6 = "UPDATE `mailinglist`.`marketing` SET `Sales` = '$newsalesmarketing' WHERE `marketing`.`Date` = '$marketingdate'";
$result6 = @mysql_query($query6, $db);
}
}
mysql_close();
?>[/PHP]
Jul 3 '07 #1
5 2712
kovik
1,044 Expert 1GB
Then there is an error with the result.

Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query($query) or echo(mysql_error());
  2. if(!is_resource($result))
  3. {
  4.     echo gettype($result);
  5. }
Jul 3 '07 #2
ak1dnar
1,584 Expert 1GB
Thread title changed – Ajaxrand
[Please Read why!]

Earlier: mysql_fetch_assoc error, so easy, yet not so... PLEASE HELP
Recent: Error in mysql_fetch_assoc()


Jul 4 '07 #3
dafodil
392 256MB
$result8 = @mysql_query("SELECT * FROM 'mailintlist'.`marketing` WHERE `Date` = '$calldate' LIMIT 0, 1", $db);



Men look at the name of the db... it's mailinglist not mailinlist....

It should be like this....

$result8 = @mysql_query("SELECT * FROM 'mailingtlist'.`marketing` WHERE `Date` = '$calldate' LIMIT 0, 1", $db);

Please try agin...

thanks....
Jul 4 '07 #4
dafodil
392 256MB
Men look at the name of the db... it's mailinglist not mailinlist....

It should be like this....

$result8 = @mysql_query("SELECT * FROM 'mailingtlist'.`marketing` WHERE `Date` = '$calldate' LIMIT 0, 1", $db);

Please try agin...

thanks....
I mean mailinglist sorry for the wrong code... (typographical error)

Here is the correct code...

$result8 = @mysql_query("SELECT * FROM 'mailinglist'.`marketing` WHERE `Date` = '$calldate' LIMIT 0, 1", $db);
Jul 4 '07 #5
I mean mailinglist sorry for the wrong code... (typographical error)

Here is the correct code...

$result8 = @mysql_query("SELECT * FROM 'mailinglist'.`marketing` WHERE `Date` = '$calldate' LIMIT 0, 1", $db);

Well actually, I tried it with out the 'mailinglist'. before the name of the table, and still got the error. I dont know if that typo was the same throughout my troubleshooting, but I do know that I will try it on Thursday when I get back to work.

Thanks for your help,
Dustin
Jul 4 '07 #6

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

Similar topics

10
by: James Campbell | last post by:
ok, I am totally new to php and come from an asp background. I basically want to do an If > then > else > end if statement: my page is: <?php require_once('Connections/carresa.php'); ?>...
3
by: Paul Lautman | last post by:
Are there any benefits to using mysql_fetch_object() instead of mysql_fetch_assoc()?
3
by: caveman | last post by:
Hi i am using PHP to upload picture files to a file in my server, but for some reason it will not create thumbnails of the upload, all that happens is that where the thumbnail is meant to be...
6
by: jsgoodrich | last post by:
I am looking for some help if anyone can lend a hand. I have a simple php website that displays a table from my mysql database. To prep for my MCSE I moved my home server to Windows 2003...
36
by: rhys | last post by:
My Gurus and Angels -- Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My...
1
by: nkosinathi | last post by:
Hi Guys im trying to write an import class where i can import information from .CSV file into my database. I am getting the following error Errors: You have an error in your SQL syntax. Check the...
2
by: fburn | last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux. I receive an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or...
1
by: RYKLOU | last post by:
I am kinda new to php, but i do know what i am doing kinda, but i came across this error when i am trying to upload a file to my website. Fatal error: Allowed memory size of 8388608 bytes...
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.