[PHP-DB] [SOLVED] Re: Weird error... (after server crash @ISP)

2017-05-28 Thread Michelle Konzack
I have not remarked, that 

> [64]  function db_query($query, $link='db_link') {

was messed up.  It should be:

  function db_query($link='db_link', $query) {

Thanks

-- 
Michelle KonzackMiila ITSystems @ TDnet
GNU/Linux Developer 00372-54541400


signature.asc
Description: Digital signature


[PHP-DB] SOLVED data from db to a page and then to another page

2009-01-08 Thread Mika Jaaksi
Thanks to all who answered and helped.


[PHP-DB] solved [Re: [PHP-DB] Re: Problem with mysql_fetch_array after first loop...]

2005-03-03 Thread Jeffrey Baumgartner
That was indeed the problem and of course I should have seen it myself!
Thanks very much, Jochem.
Jeffrey
Jochem Maas wrote:
Steve McGill wrote:
"Jeffrey Baumgartner" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
I've made a little programme that deletes expired records from database
tables. The troublesome bit looks like this...
   $query = "SELECT ic FROM ic_ic WHERE date <= CURDATE()";
   $result = mysql_query($query) or die("Unable to get old
campaigns because " . mysql_error());
   while ($row = mysql_fetch_array($result)){
   extract($row);
...delete records from tables where ic = ic


are you by any chance doing a query inside this while loop?
if you are then make sure you assign the result of the call to 
mysql_query()
to a variable that is NOT called $result.

  }
It works fine for the fitst value of $ic, but on the second time around
I get an error message saying that line [starting with "while..."] is
not a valid MySQL resource. This really puzzles me because it works one
time around, but not after that.

print_r(), var_dump() (and plain echo or print) are your friends:
if you preceed the line starting 'while ($row =' with the following:
var_dump( $result );
and then also add such a statement at the bottom of your while code ie:
var_dump( $result );
while ($row = mysql_fetch_array($result)) {
extract($row); // not a good idea IMHO
// do your stuff
var_dump( $result );
}   

then you should see it change on the second call to var_dump(), which
will hopefully lead you to the code that changes the $result var when
you don't want it to change.
$ic, incidentally, is a string originally generated from the timestamp
(ie. getdate[0])  - could this be causing a problem?

Why don't you try it without using extract($row), and use 
$row[variable1]
$row[variable2] instead in your loops.
extract() pulls all the variables into the global namespace and can 
be quite
dangerous as it might overwrite other variables. (this might be whats
happening with the $result variable for example.
also, how does extract() behave when trying to convert the [0] [1] [2]
variables? you might be better off using mysql_fetch_assoc()

ditto, dont extract() in this situation - its a waste of a function 
call and a
waste of variable initialization... just use the values in the $row 
array directly... e.g.

echo $row['ic']; // this could have been $ic if you had called 
extract($row)

Best wishes,
Steve

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] [SOLVED]Re: [PHP-DB] Search results page not working with table joins

2004-10-25 Thread Stuart Felenstein

--- Stuart Felenstein <[EMAIL PROTECTED]> wrote:

> I have a search page and a results page.  It's a
> dynamic search.  It works great with just the main
> table, but as soon as I add in the table joins (to
> translate the codes) it just dumps out all the
> records
> regardless of criteria.
> 
> Here is the script without the joins:
> 
>  $currentPage = $_SERVER["PHP_SELF"];
> 
> if (isset($HTTP_GET_VARS['AdvSearch']) == false ||
> $HTTP_GET_VARS['AdvSearch']=="")
>   exit();
> $hasSQLWhereClause=false;
> $whereClause="";
> $MM_whereConst=" ";
> $fieldValue = $HTTP_GET_VARS['PostStart'];
> if(isset($HTTP_GET_VARS['PostStart']) &&
> $HTTP_GET_VARS['PostStart'] != "")
> {
>   if($hasSQLWhereClause == false)
>   {
> $hasSQLWhereClause=true;
> $whereClause=$whereClause."
> rtrim(ltrim(upper(PostStart))) =
> rtrim(ltrim(upper($fieldValue)))";
>   }
>   else
>   {
> $whereClause=$whereClause." and
> rtrim(ltrim(upper(PostStart))) =
> rtrim(ltrim(upper($fieldValue)))";
>   }
> }
> $fieldValue = $HTTP_GET_VARS['JobTitle'];
> if(isset($HTTP_GET_VARS['JobTitle']) &&
> $HTTP_GET_VARS['JobTitle']!= "")
> {
>   if($hasSQLWhereClause == false)
>   {
> $hasSQLWhereClause=true;
> $whereClause=$whereClause."
> rtrim(ltrim(upper(JobTitle))) like
> rtrim(ltrim(upper('%$fieldValue%')))";
>   }
>   else
>   {
> $whereClause=$whereClause." and
> rtrim(ltrim(upper(JobTitle))) like
> rtrim(ltrim(upper('%$fieldValue%')))";
>   }
> }
> if(isset($HTTP_GET_VARS['Industry2']))
> {
>   $colValue = $HTTP_GET_VARS['Industry2'];
>   $orCtr = 1;
>   if ($hasSQLWhereClause == false)
>   {
> $hasSQLWhereClause=true;
> $whereClause=$whereClause."(";
> foreach($colValue as $fieldValue) 
> {
>  
>
$whereClause=$whereClause."rtrim(ltrim(upper(Industry)))
> = rtrim(ltrim(upper('$fieldValue')))";
>   if($orCtr < count($colValue))
>   {
>   $whereClause=$whereClause." or ";
>   }
>   $orCtr++;
> }
> $whereClause=$whereClause.")";
>   }
>   else
>   {
> $whereClause=$whereClause." and (";
> foreach($colValue as $fieldValue)
> {
>  
>
$whereClause=$whereClause."rtrim(ltrim(upper(Industry)))
> = rtrim(ltrim(upper('$fieldValue')))";
>   if($orCtr < count($colValue))
>   {
>   $whereClause=$whereClause." or ";
>   }
>   $orCtr++;
> }
> $whereClause=$whereClause.")";
>   }
> }
> $fieldValue = $HTTP_GET_VARS['LocationCity'];
> if(isset($HTTP_GET_VARS['LocationCity']) &&
> $HTTP_GET_VARS['LocationCity']!= "")
> {
>   if($hasSQLWhereClause == false)
>   {
> $hasSQLWhereClause=true;
> $whereClause=$whereClause."
> rtrim(ltrim(upper(LocationCity))) like
> rtrim(ltrim(upper('%$fieldValue%')))";
>   }
>   else
>   {
> $whereClause=$whereClause." and
> rtrim(ltrim(upper(LocationCity))) like
> rtrim(ltrim(upper('%$fieldValue%')))";
>   }
> }
> if(isset($HTTP_GET_VARS['LocationState2']))
> {
>   $colValue = $HTTP_GET_VARS['LocationState2'];
>   $orCtr = 1;
>   if ($hasSQLWhereClause == false)
>   {
> $hasSQLWhereClause=true;
> $whereClause=$whereClause."(";
> foreach($colValue as $fieldValue) 
> {
>  
>
$whereClause=$whereClause."rtrim(ltrim(upper(LocationState)))
> = rtrim(ltrim(upper('$fieldValue')))";
>   if($orCtr < count($colValue))
>   {
>   $whereClause=$whereClause." or ";
>   }
>   $orCtr++;
> }
> $whereClause=$whereClause.")";
>   }
>   else
>   {
> $whereClause=$whereClause." and (";
> foreach($colValue as $fieldValue)
> {
>  
>
$whereClause=$whereClause."rtrim(ltrim(upper(LocationState)))
> = rtrim(ltrim(upper('$fieldValue')))";
>   if($orCtr < count($colValue))
>   {
>   $whereClause=$whereClause." or ";
>   }
>   $orCtr++;
> }
> $whereClause=$whereClause.")";
>   }
> }
> if(isset($HTTP_GET_VARS['TaxTerm2']))
> {
>   $colValue = $HTTP_GET_VARS['TaxTerm2'];
>   $orCtr = 1;
>   if ($hasSQLWhereClause == false)
>   {
> $hasSQLWhereClause=true;
> $whereClause=$whereClause."(";
> foreach($colValue as $fieldValue) 
> {
>  
>
$whereClause=$whereClause."rtrim(ltrim(upper(TaxTerm)))
> = rtrim(ltrim(upper('$fieldValue')))";
>   if($orCtr < count($colValue))
>   {
>   $whereClause=$whereClause." or ";
>   }
>   $orCtr++;
> }
> $whereClause=$whereClause.")";
>   }
>   else
>   {
> $whereClause=$whereClause." and (";
> foreach($colValue as $fieldValue)
> {
>  
>
$whereClause=$whereClause."rtrim(ltrim(upper(TaxTerm)))
> = rtrim(ltrim(upper('$fieldValue')))";
>   if($orCtr < count($colValue))
>   {
>   $whereClause=$whereClause." or ";
>   }
>   $orCtr++;
> }
> $whereClause=$whereClause.")";
>   }
> }
> if($whereClause != "")
>   $MM_whereConst="WHERE";
> 
> $maxRows_RecordSet1 = 10;
> $pageNum_RecordSet1 = 0;
> if (isset($HTTP_GET_VARS['pageNum_RecordSet1'])) {
> 

[PHP-DB] solved

2004-05-08 Thread Florian Wagner
"Torsten Roehr" <[EMAIL PROTECTED]> schrieb im Newsbeitrag >
> This can be done with eval():
> http://de.php.net/manual/en/function.eval.php
>
> Take a look at the user comments there, especially regarding the inclusion
> of .
>

That was extremely useful :) thank you so much
I now use the function "eval_html" posted at the address mentioned by
torsten and it works fine!
Looks like these users at php.net know what they're talking about ;)

Bye

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] [SOLVED] Re: problem - query inside a function

2003-10-15 Thread Kirk Babb
Thanks to Karen and Richard for your help!

I removed the quotes around 0 in the comparison for mysql_affected_rows.
That was definitely important.

I then added the echo $sql; statement Richard recommended, and saw the
following:
(save some time and just look at the end of the string)

 SELECT * FROM contact_info WHERE zipcode='86345' AND
email="[EMAIL PROTECTED]"&result=Fail&errorMsg=We+do+not+have+the+given+email+and+zi
pcode+on+file.++Please+go+to+the+menu+and+start+again.&result=Edit

I had completely missed that!  That was overriding my &result=Fail earlier
in the string, so naturally it was going to the edit page.  Doh!

Looking thru my code I had a hard time figuring it out (although it's seems
simple now):

1 function getEditData($email,$zipcode) {
2   $sql = "SELECT * FROM contact_info WHERE zipcode='$zipcode' AND
email=\"{$email}\"";
3echo $sql;
4$query = mysql_query($sql);
5if (mysql_affected_rows()==0) {
6  $this->sendResult("Fail","We do not have the given email and zipcode
on file.  Please go to the menu and start again.");
7} else {
8   //a bunch of variables declared here so I pulled them out for space
9$this->sendResult("Edit",$varsToEdit);
10  }

Even though I was invoking the function sendResult for the failure, the code
was continuing on to the NEXT sendResult which was giving the Edit message.
Here is the sendResult function:

11 function sendResult($result,$txtMsg) {
12switch ($result) {
13case "Okay":
14$txtMsg = urlencode($txtMsg);
15   print "&result=Okay&successMsg=" . $txtMsg;
16break;
17  case "Fail":
18$txtMsg = urlencode($txtMsg);
19print "&result=Fail&errorMsg=" . $txtMsg;
20break;
21  case "Edit":
22print "&result=Edit&" . $txtMsg;
23break;
24}
25  }

So result was being sent twice, and the second value(sent on line 22) for
result overrode the first (on line19)  The Solution?  Add a break;
inside the first "if" after line 6.  Problem solved because the script stops
(which it should at that point).

WOW, I hope you guys don't mind me sharing all of that, maybe it will help
somebody else in the future - make sure you terminate your failure cases if
you're calling another function to handle the job.

Thanks again for the help :)

Kirk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] SOLVED=> 'while' not picking up on first DB record

2003-09-17 Thread Roger Spears
I'm sorry for the double post.  Other then letting both lists know this 
was solved, it won't happen again.  Sorry.

Thank you for the solution!

I new it was simple.  I've been staring at it too long.  Fresh eyes 
always helps!

Thanks again,
Roger
You are making the fetch twice, and not using the first fetch.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] ***SOLVED *** query works fine on console but not with PHP ***SOLVED***

2003-08-03 Thread Aaron Wolski

Hi,

Seem to still be getting responses to this question. I don't want people
to take time out from what their doing to answer a question that is now
solved.

Just trying to help save some people the time and effort from their own
development.

Much appreciated answers though. They'll help me in future debugging.

Thanks again to all.

Aaron
-Original Message-
From: Aaron Wolski [mailto:[EMAIL PROTECTED] 
Sent: August 3, 2003 10:08 AM
To: 'Matt'; '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] query works fine on console but not with PHP -
why? SOLVED

Hi and thanks,

Actually.. there was a typo in an if() statement just prior to it that
checked to see if a variable was set before proceeding with the query.

What a dumb-ass I am. You know you've been working way to long when you
can't do simple things.

Thanks for your comments!

Aaron

-Original Message-
From: Matt [mailto:[EMAIL PROTECTED] 
Sent: August 3, 2003 10:11 AM
To: Aaron Wolski; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] query works fine on console but not with PHP -
why?


- Original Message - 
From: "Aaron Wolski" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 03, 2003 9:59 AM
Subject: [PHP-DB] query works fine on console but not with PHP - why?
> The error I am getting on the browser is:
>  
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
> result resource in http://www.martekbiz.com/KCS/utils.inc on line 52
>  
> Anyone have an idea as to what it up?

Try:
echo mysql_error();

 and see what mysql says.




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Solved! Re: initialize assoc arrays

2003-03-31 Thread Charles Kline
Hey. I just figured it out! So simple too :)

$myarray = array();
foreach ($sth_opt as $thekey => $thevalue){
$myarray[$thevalue] = true;
}
On Monday, March 31, 2003, at 06:05 PM, Charles Kline wrote:

hi all, i am changing the title are reposting - i have a clearer idea 
now of what i am trying to do...

what is the syntax to initialize an associative array with values 
returned in a query where the key in the array is coming from the 
query and the value is static value of true?

i want to create an array that 'could' look like this:

$myarray = array('31'=>true,'21'=>true);

where 31 and 21 are the values returned from query

thanks,
charles
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Solved! -- Buuuuttt.

2001-09-24 Thread Jason Caldwell

In the PHP.INI file I had to set REGISTER_GLOBALS = off

The Vars are registering -- but not with an INCLUDE file or FUNCTION
plus, my INPUT tag data (vars) aren't coming over...

What the #%#^ is go'in?

Very frustrating any help would be greatly appreciated.

Thanks
Jason



"Jason Caldwell" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I'm trying to use HTTP_SESSION_VARS all over my scripts for security
> reasons.  However, for some reason, when I do the following the var isn't
> updated in the session file... anyone know why?
>
> session_start();
> session_register("s_myvar");
>
> $HTTP_SESSION_VARS["s_myvar"] = 1;
>
> If I assign the value to just the var it works fine.
>
> $s_myvar = 1;
>
> Thanks.
> Jason
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] SOLVED SORRY - Delete all Data and keep the Table

2001-04-02 Thread Naga Sean

How to delete all the data in database, without delete the table.
Looks like I can't delete all the data with single click in PHPmyAdmin mySQL

-naga

_
www.kaskus.com - FREE EMAIL SERVICE

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]