Jump to content

query wont insert?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
19 replies to this topic

#1
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
ok, so I dont understand why this script isnt working..

					if(isset($ASP)){ $ASP = "yes"; } Else { $ASP = "no"; }

					if(isset($PHP)){ $PHP = "yes"; } Else { $PHP = "no"; }

					if(isset($java)){ $java = "yes"; } Else { $java = "no"; }

					if(isset($python)){ $python = "yes"; } Else { $python = "no"; }

					if(isset($perl)){ $perl = "yes"; } Else { $perl = "no"; }

					if(isset($JDK)){ $JDK = "yes"; } Else { $JDK = "no"; }

					if(isset($flash)){ $flash = "yes"; } Else { $flash = "no"; }

					if(isset($ruby)){ $ruby = "yes"; } Else { $ruby = "no"; }

					if(isset($tomcat)){ $tomcat = "yes"; } Else { $tomcat = "no"; }

					if(isset($SSI)){ $SSI = "yes"; } Else { $SSI = "no"; }

					if(isset($CGI)){ $CGI = "yes"; } Else { $CGI = "no"; }

					if(isset($cpanel)){ $cpanel = "yes"; } Else { $cpanel = "no"; }

					if(isset($SQL)){ $SQL = "yes"; } Else { $SQL = "no"; }

					if(isset($emails)){ $emails = "yes"; } Else { $emails = "no"; }

					if(isset($subdomains)){ $subdomains = "yes"; } Else { $subdomains = "no"; }

					if(isset($SSH)){ $SSH = "yes"; } Else { $SSH = "no"; }

					if(isset($sitebuilder)){ $sitebuilder = "yes"; } Else { $sitebuilder = "no"; }

					$date = date("m.d.y"); 

					$query="UPDATE webmasters SET hostemail='$newhostemail', hosttitle='$newhosttitle', hosturl='$newhosturl', profile='$newprofile', OS='$newOS', PHP='$PHP', ASP='$ASP', java='$java', python='$python', JDK='$JDK', flash='$flash', ruby='$ruby', tomcat='$tomcat', SSI='$SSI', CGI='$CGI', cpanel='$cpanel', SQL='$SQL', emails='$emails', subdomains='$subdomains', SSH='$SSH', sitebuilder='$sitebuilder', lastupdated='$date', WHERE id='$id'";

					mysql_query($query);

					

					$noticetitle = "Success";

					$noticedata = "Your Profile Has Been Updated";

					$refresh = "index.php?action=viewhost&hostid=$id";

					include("notice.php");

It will say success, your profile has been updated, but wont update, or give me an SQL error, do you guys see something wrong with it? I feel stupid asking

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Instead of mysql_query($query); try:

mysql_query($query) or die('Error in query: '.$query.' : '.mysql_error($connection));


and see if MySQL throws an error.

Edited by Jordan, 01 May 2008 - 02:46 PM.


#3
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
awesome.. I see the error. its adding the HTML and throwing an error (I believe)

Quote

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/analyzet/public_html/editprofile.php on line 149
Error in query: UPDATE webmasters SET hostemail='support@analyzethathost.com', hosttitle='Digital Euphoria', hosturl='http://google.com', profile='


The greatest profile ever!\\\'\\\'\\\"\\\"$username', OS='lincentos5', PHP='yes', ASP='yes', java='yes', python='yes', JDK='yes', flash='yes', ruby='yes', tomcat='yes', SSI='yes', CGI='yes', cpanel='yes', SQL='yes', emails='yes', subdomains='yes', SSH='yes', sitebuilder='yes', lastupdated='05.01.08', WHERE id='1' :

addshashes isnt working..
how do I add HTML into an SQL field?

EDIT: after Profile='
there is a ton of HTML, just wont show on codecall

Edited by phpforfun, 01 May 2008 - 03:56 PM.
edit


#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Use the htmlentities() function on the string:

IE:
$profile = htmlentities($profile);

Before you insert it into the DB. You can read more about the function here: PHP: htmlentities - Manual

#5
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
That doesnt seem to work, but I will work with it

#6
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
Turn magic quotes off [they wont exist in php 6], and prior to inserting strings into the database, run them through mysql_real_escape_string(). Don't bother with htmlentities, adding or stripping slashes before inserting html into a database. Worry about them when you display the html.

#7
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
Hum.. I tried that too john, doesnt work..

feel free to log in and test it.

Analyze That Host
click login
use "Justin" and "pass"
after you login, hover over "member actions" (where login was), and click edit host profile

and then just edit whatever

here is the code
					$newprofile = mysql_real_escape_string($newprofile);
					$query="UPDATE webmasters SET hostemail='$newhostemail', hosttitle='$newhosttitle', hosturl='$newurl', profile='$newprofile', OS='$newOS', PHP='$PHP', ASP='$ASP', java='$java', python='$python', JDK='$JDK', flash='$flash', ruby='$ruby', tomcat='$tomcat', SSI='$SSI', CGI='$CGI', cpanel='$cpanel', SQL='$SQL', emails='$emails', subdomains='$subdomains', SSH='$SSH', sitebuilder='$sitebuilder', lastupdated='$date', WHERE id='$id'";
					mysql_query($query) or die('Error in query: '.$query.' : '.mysql_error($connection));  
					
					$noticetitle = "Success";
					$noticedata = "Your Profile Has Been Updated";
					$refresh = "index.php?action=viewhost&hostid=$id";
					include("notice.php");


EDIT: The sql type is set as "text", is that ok?

Edited by phpforfun, 02 May 2008 - 12:16 PM.
sql stuff


#8
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I was hoping John would reply to this thread. When you run John's suggestion, do you get the same MySQL error?

#9
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
yeah i do

why were you hoping he would reply?

#10
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
I will have a look at this more closely in a few hours. PM me where this file is located on your account, so I can have a closer look. :)

#11
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
yes sir!

#12
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
Well you no longer receive a mysql error (you had three errors), and parts of the hosts profile update. Not sure why the Profile Content bit doesn't update...

Also "loggedin" (when you log in) is spelled wrong. :)