vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Um.. Apostrophes and PHP.. (https://vborg.vbsupport.ru/showthread.php?t=42247)

Coolj 08-13-2002 06:26 PM

Um.. Apostrophes and PHP..
 
Um.. Apostrophes and PHP..

I use ashnews

and recently in my new host when I submit something with an apostrophe it gives me a mysql connect error, but when I put a \ in front it goes through.. ex

Quote:

He's a good fella.
Will not go through..

Quote:

He \ ' s a good fella.
Will go through.

mr e 08-13-2002 06:58 PM

i dont know what the question was, but if you do an apostrophe or a quote you have to escape it with a \ before it

Coolj 08-13-2002 06:59 PM

If there any way around this? Like by using str_replace?

mr e 08-13-2002 07:07 PM

oh ok, well to automatically escape EVERYTHING you surround the string with '' (single quotes) but if you do
PHP Code:

<?
$test = blue;
print 'the sky is $test';
?>

that wont work because $test is automatically escaped, but if you dont have any variables in it then single quotes would work

Coolj 08-13-2002 07:12 PM

Hmm..

Coolj 08-13-2002 07:29 PM

Everytime I submitted something with an apostrophe, i'd get a mysql cannot connect error. A friend of mine told me how to fix it..

<?php
$textarea = addslashes($textarea);
?>

Ajay 08-18-2002 09:02 PM

use stripslashes()
i.e
PHP Code:

$bad 'good'
$string 'Cupcakes are $bad"'
echo 
$string

$string addslashes($string); 
eval(
"\$string = \"$string\";"); 
$string stripslashes($string); 

echo 
$string



All times are GMT. The time now is 01:47 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01121 seconds
  • Memory Usage 1,725KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete